This commit is contained in:
syuilo
2018-05-20 20:26:38 +09:00
parent 2e6905c74c
commit b20b975935
48 changed files with 146 additions and 158 deletions

View File

@ -2,17 +2,12 @@
* Replace i18n texts
*/
export const pattern = /%i18n:([a-z0-9_\-@\.\!]+?)%/g;
export const pattern = /%i18n:([a-z0-9_\-@\.]+?)%/g;
export const replacement = (ctx, match, key) => {
const client = '/src/client/app/';
let name = null;
const shouldEscape = key[0] == '!';
if (shouldEscape) {
key = key.substr(1);
}
if (key[0] == '@') {
name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
key = key.substr(1);
@ -20,5 +15,5 @@ export const replacement = (ctx, match, key) => {
const path = name ? `${name}|${key}` : key;
return shouldEscape ? `%i18n:!${path}%` : `%i18n:${path}%`;
return `%i18n:${path}%`;
};