Merge pull request #329 from mewtaylor/bugfix/localize-nonlocalized-views

Add general localizations to nonlocalized pages
This commit is contained in:
Matthew Taylor 2016-01-22 10:25:09 -05:00
commit 75ea8a7304

View file

@ -90,6 +90,12 @@ for (var id in generalIds) {
icuWithIds[generalIds[id]] = 'general-' + id; icuWithIds[generalIds[id]] = 'general-' + id;
} }
// start with all views, and remove localized ones as they are iterated over
var views = glob.sync(path.resolve(__dirname, '../src/views/*'));
for (var i = 0; i < views.length; i++) {
views[i] = views[i].split('/').pop();
}
// get view-specific locale strings. // get view-specific locale strings.
var files = glob.sync(path.resolve(__dirname, '../src/views/**/l10n.json')); var files = glob.sync(path.resolve(__dirname, '../src/views/**/l10n.json'));
files.forEach(function (file) { files.forEach(function (file) {
@ -152,10 +158,13 @@ glob(poUiDir + '/*', function (err, files) {
} }
}); });
for (var view in viewLocales) { for (var i in views) {
var viewTranslations = merge(viewLocales[view], generalLocales); var viewTranslations = generalLocales;
if (views[i] in viewLocales) {
viewTranslations = merge(viewLocales[views[i]], viewTranslations);
}
var objectString = JSON.stringify(viewTranslations); var objectString = JSON.stringify(viewTranslations);
var fileString = 'window._messages = ' + objectString + ';'; var fileString = 'window._messages = ' + objectString + ';';
fs.writeFileSync(outputDir + '/' + view + '.intl.js', fileString); fs.writeFileSync(outputDir + '/' + views[i] + '.intl.js', fileString);
} }
}); });