Move custom translation strings to its own file (#775)

This commit is contained in:
Joel Marcey 2018-06-14 17:25:29 -07:00 committed by GitHub
parent fd9a3ffb6d
commit 608e2c85a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 6 deletions

View file

@ -20,13 +20,13 @@ const babylon = require('babylon');
const traverse = require('babel-traverse').default;
const sidebars = require(CWD + '/sidebars.json');
let currentTranslations = {
let customTranslations = {
'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')) {
customTranslations = JSON.parse(
fs.readFileSync(CWD + '/data/custom-translation-strings.json', 'utf8')
);
}
@ -158,11 +158,11 @@ function execute() {
'Translate';
translations['pages-strings'] = Object.assign(
translations['pages-strings'],
currentTranslations['pages-strings']
customTranslations['pages-strings']
);
translations['localized-strings'] = Object.assign(
translations['localized-strings'],
currentTranslations['localized-strings']
customTranslations['localized-strings']
);
writeFileAndCreateFolder(
CWD + '/i18n/en.json',