1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-30 15:58:19 +09:00
cherrypick/webpack/i18n.ts
2018-08-25 22:42:26 +09:00

20 lines
400 B
TypeScript

/**
* Replace i18n texts
*/
export const pattern = /%i18n:([a-z0-9_\-@\.]+?)%/g;
export const replacement = (ctx: any, _: any, key: string) => {
const client = '/src/client/app/';
let name = null;
if (key.startsWith('@')) {
name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
key = key.substr(1);
}
const path = name ? `${name}|${key}` : key;
return `%i18n:${path}%`;
};