2018-05-17 03:28:31 +03:00
|
|
|
/**
|
|
|
|
* Replace i18n texts
|
|
|
|
*/
|
|
|
|
|
2018-05-20 14:26:38 +03:00
|
|
|
export const pattern = /%i18n:([a-z0-9_\-@\.]+?)%/g;
|
2018-05-17 03:28:31 +03:00
|
|
|
|
2018-06-18 03:54:53 +03:00
|
|
|
export const replacement = (ctx: any, _: any, key: string) => {
|
2018-05-17 03:28:31 +03:00
|
|
|
const client = '/src/client/app/';
|
|
|
|
let name = null;
|
|
|
|
|
2018-08-25 16:42:26 +03:00
|
|
|
if (key.startsWith('@')) {
|
2018-05-17 03:28:31 +03:00
|
|
|
name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
|
|
|
|
key = key.substr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const path = name ? `${name}|${key}` : key;
|
|
|
|
|
2018-05-20 14:26:38 +03:00
|
|
|
return `%i18n:${path}%`;
|
2018-05-17 03:28:31 +03:00
|
|
|
};
|