From ae6acb5f3d61877ed07487090c14a8a0bb064b0d Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 31 Mar 2017 01:25:09 +0900 Subject: [PATCH] .yaml -> .yml --- webpack.config.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/webpack.config.ts b/webpack.config.ts index 71374daa9..d4a3ff09d 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -11,8 +11,8 @@ import version from './src/version'; const constants = require('./src/const.json'); const languages = { - 'en': yaml.safeLoad(fs.readFileSync('./locales/en.yaml', 'utf-8')), - 'ja': yaml.safeLoad(fs.readFileSync('./locales/ja.yaml', 'utf-8')) + 'en': yaml.safeLoad(fs.readFileSync('./locales/en.yml', 'utf-8')), + 'ja': yaml.safeLoad(fs.readFileSync('./locales/ja.yml', 'utf-8')) }; const env = process.env.NODE_ENV; @@ -35,23 +35,25 @@ module.exports = (Object as any).entries(languages).map(([lang, locale]) => { exclude: /node_modules/, loader: StringReplacePlugin.replace({ replacements: [ - { pattern: /%i18n:(.+?)%/g, replacement: (_, key) => { - let text = locale; - const error = key.split('.').some(k => { - if (text.hasOwnProperty(k)) { - text = text[k]; - return false; + { + 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 true; + return text.replace(/'/g, '\\\'').replace(/"/g, '\\"'); } - }); - if (error) { - console.warn(`key '${key}' not found in '${lang}'`); - return '-UNTRANSLATED-'; - } else { - return text.replace(/'/g, '\\\'').replace(/"/g, '\\"'); } - } } + } ] }) },