Archived
1
0
This repository has been archived on 2025-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
mi.moris.day/webpack/i18n.ts
2018-06-18 09:54:53 +09:00

20 lines
394 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[0] == '@') {
name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
key = key.substr(1);
}
const path = name ? `${name}|${key}` : key;
return `%i18n:${path}%`;
};