diff options
author | Ondřej Hruška <ondra@ondrovo.com> | 2017-07-16 01:15:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-16 01:15:25 +0200 |
commit | 3ea02314b951b42b1d5ee0cfc0a7aa9104050665 (patch) | |
tree | 7ea0649f1ede4d1f0515238af6ff87f248651dd3 /config | |
parent | 4715161a93e8ca4ec8c9865deefa48e08fd8e878 (diff) |
split added glitch locales from vanilla (#82)
* Locale script now accepts overrides and new keys from glitch/locales * Revert glitchsoc changes to mastodon/locales to prevent future merge conflicts
Diffstat (limited to 'config')
-rw-r--r-- | config/webpack/generateLocalePacks.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/config/webpack/generateLocalePacks.js b/config/webpack/generateLocalePacks.js index b71cf2ade..cd3bed50c 100644 --- a/config/webpack/generateLocalePacks.js +++ b/config/webpack/generateLocalePacks.js @@ -34,6 +34,23 @@ locales.forEach(locale => { ].filter(filename => fs.existsSync(path.join(outPath, filename))) .map(filename => filename.replace(/..\/..\/node_modules\//, ''))[0]; + let glitchInject = ` +const mergedMessages = messages; +`; + + const glitchPath = `../../app/javascript/glitch/locales/${locale}.json`; + if (fs.existsSync(path.join(outPath, glitchPath))) { + glitchInject = ` +import glitchMessages from ${JSON.stringify(glitchPath)}; + +let mergedMessages = messages; +Object.keys(glitchMessages).forEach(function (key) { + mergedMessages[key] = glitchMessages[key]; +}); + +`; + } + const localeContent = `// // locale_${locale}.js // automatically generated by generateLocalePacks.js @@ -41,7 +58,8 @@ locales.forEach(locale => { import messages from '../../app/javascript/mastodon/locales/${locale}.json'; import localeData from ${JSON.stringify(localeDataPath)}; import { setLocale } from '../../app/javascript/mastodon/locales'; -setLocale({messages, localeData}); +${glitchInject} +setLocale({messages: mergedMessages, localeData: localeData}); `; fs.writeFileSync(localePath, localeContent, 'utf8'); outPaths.push(localePath); |