1
0
Fork 0
mirror of https://github.com/paricafe/misskey.git synced 2025-02-17 17:07:28 -06:00
paricafe/webpack/i18n.ts

20 lines
400 B
TypeScript
Raw Normal View History

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