.yaml -> .yml

This commit is contained in:
Aya Morisawa 2017-03-31 01:25:09 +09:00
parent fb04f87a0b
commit ae6acb5f3d

View file

@ -11,8 +11,8 @@ import version from './src/version';
const constants = require('./src/const.json'); const constants = require('./src/const.json');
const languages = { const languages = {
'en': yaml.safeLoad(fs.readFileSync('./locales/en.yaml', 'utf-8')), 'en': yaml.safeLoad(fs.readFileSync('./locales/en.yml', 'utf-8')),
'ja': yaml.safeLoad(fs.readFileSync('./locales/ja.yaml', 'utf-8')) 'ja': yaml.safeLoad(fs.readFileSync('./locales/ja.yml', 'utf-8'))
}; };
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
@ -35,23 +35,25 @@ module.exports = (Object as any).entries(languages).map(([lang, locale]) => {
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ loader: StringReplacePlugin.replace({
replacements: [ replacements: [
{ pattern: /%i18n:(.+?)%/g, replacement: (_, key) => { {
let text = locale; pattern: /%i18n:(.+?)%/g, replacement: (_, key) => {
const error = key.split('.').some(k => { let text = locale;
if (text.hasOwnProperty(k)) { const error = key.split('.').some(k => {
text = text[k]; if (text.hasOwnProperty(k)) {
return false; text = text[k];
return false;
} else {
return true;
}
});
if (error) {
console.warn(`key '${key}' not found in '${lang}'`);
return '-UNTRANSLATED-';
} else { } 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, '\\"');
} }
} } }
] ]
}) })
}, },