Commit a0d92dac authored by Matthew Taylor's avatar Matthew Taylor

Add general localizations to nonlocalized pages

For nav/footer purposes.
parent 5e055fb6
...@@ -90,12 +90,21 @@ for (var id in generalIds) { ...@@ -90,12 +90,21 @@ 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 nonLocalizedViews = glob.sync(path.resolve(__dirname, '../src/views/*'));
for (var i = 0; i < nonLocalizedViews.length; i++) {
nonLocalizedViews[i] = nonLocalizedViews[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) {
var dirPath = file.split('/'); var dirPath = file.split('/');
dirPath.pop(); dirPath.pop();
var view = dirPath.pop(); var view = dirPath.pop();
if (nonLocalizedViews.indexOf(view) > -1) {
nonLocalizedViews.splice(nonLocalizedViews.indexOf(view), 1);
}
var viewIds = JSON.parse(fs.readFileSync(file, 'utf8')); var viewIds = JSON.parse(fs.readFileSync(file, 'utf8'));
viewLocales[view] = { viewLocales[view] = {
...@@ -158,4 +167,11 @@ glob(poUiDir + '/*', function (err, files) { ...@@ -158,4 +167,11 @@ glob(poUiDir + '/*', function (err, files) {
var fileString = 'window._messages = ' + objectString + ';'; var fileString = 'window._messages = ' + objectString + ';';
fs.writeFileSync(outputDir + '/' + view + '.intl.js', fileString); fs.writeFileSync(outputDir + '/' + view + '.intl.js', fileString);
} }
// Add general localization strings for non localized views, to account for nav/footer.
for (var i in nonLocalizedViews) {
objectString = JSON.stringify(generalLocales);
fileString = 'window._messages = ' + objectString + ';';
fs.writeFileSync(outputDir + '/' + nonLocalizedViews[i] + '.intl.js', fileString);
}
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment