Skip to content

Commit

Permalink
[RFC] Move custom translation strings to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelMarcey committed Jun 14, 2018
1 parent 23bda1b commit ab1ca99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/write-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const babylon = require('babylon');
const traverse = require('babel-traverse').default;
const sidebars = require(CWD + '/sidebars.json');

let currentTranslations = {
let overrideTranslations = {
'localized-strings': {},
'pages-strings': {},
};
if (fs.existsSync(CWD + '/i18n/en.json')) {
currentTranslations = JSON.parse(
fs.readFileSync(CWD + '/i18n/en.json', 'utf8')
if (fs.existsSync(CWD + '/data/custom-translation-strings.json')) {
overrideTranslations = JSON.parse(
fs.readFileSync(CWD + '/data/custom-translation-strings.json', 'utf8')
);
}

Expand Down Expand Up @@ -158,11 +158,11 @@ function execute() {
'Translate';
translations['pages-strings'] = Object.assign(
translations['pages-strings'],
currentTranslations['pages-strings']
overrideTranslations['pages-strings']
);
translations['localized-strings'] = Object.assign(
translations['localized-strings'],
currentTranslations['localized-strings']
overrideTranslations['localized-strings']
);
writeFileAndCreateFolder(
CWD + '/i18n/en.json',
Expand Down
9 changes: 9 additions & 0 deletions website/data/custom-translation-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"_comment": "This file is used to provide custom strings for translations, including overriding defaults",
"localized-strings": {
"translation": "Translations and Localization"
},
"pages-strings" : {
"Help Translate|recruit community translators for your project": "Help Us Translate"
}
}

0 comments on commit ab1ca99

Please sign in to comment.