2018-05-16 17:28:31 -07:00
|
|
|
/**
|
|
|
|
* Replace i18n texts
|
|
|
|
*/
|
|
|
|
|
2018-05-20 04:26:38 -07:00
|
|
|
export const pattern = /%i18n:([a-z0-9_\-@\.]+?)%/g;
|
2018-05-16 17:28:31 -07:00
|
|
|
|
|
|
|
export const replacement = (ctx, match, key) => {
|
|
|
|
const client = '/src/client/app/';
|
|
|
|
let name = null;
|
|
|
|
|
|
|
|
if (key[0] == '@') {
|
|
|
|
name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
|
|
|
|
key = key.substr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const path = name ? `${name}|${key}` : key;
|
|
|
|
|
2018-05-20 04:26:38 -07:00
|
|
|
return `%i18n:${path}%`;
|
2018-05-16 17:28:31 -07:00
|
|
|
};
|