diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-26 03:23:19 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-26 03:23:19 +0900 |
| commit | 7dd709f8a63bf55e4f57d216d22b55b7ab3d91d7 (patch) | |
| tree | 7532b651687c9611d8b191179d58fd5b6136bae4 /webpack.config.ts | |
| parent | [Client:Desktop] Add link (diff) | |
| download | misskey-7dd709f8a63bf55e4f57d216d22b55b7ab3d91d7.tar.gz misskey-7dd709f8a63bf55e4f57d216d22b55b7ab3d91d7.tar.bz2 misskey-7dd709f8a63bf55e4f57d216d22b55b7ab3d91d7.zip | |
wip #313
Diffstat (limited to 'webpack.config.ts')
| -rw-r--r-- | webpack.config.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/webpack.config.ts b/webpack.config.ts index b67c0e9036..b501eb1efd 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -33,7 +33,23 @@ module.exports = (Object as any).entries(languages).map(([lang, locale]) => { exclude: /node_modules/, loader: StringReplacePlugin.replace({ replacements: [ - { pattern: /%i18n:(.+?)%/g, replacement: (_, text) => eval('locale' + text.split('.').map(x => `['${x}']`).join('')) } + { pattern: /%i18n:(.+?)%/g, replacement: (_, key) => { + let text = locale; + const error = key.split('.').some(k => { + if (text.hasOwnProperty(k)) { + text = text[k]; + return false; + } else { + return true; + } + }); + if (error) { + console.warn(`key '${key}' not found in '${lang}'`); + return '-UNTRANSLATED-'; + } else { + return text.replace(/'/g, '\\\'').replace(/"/g, '\\"'); + } + } } ] }) }, |