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
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user