mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 08:49:51 +02:00
Move custom translation strings to its own file (#775)
This commit is contained in:
parent
fd9a3ffb6d
commit
608e2c85a2
3 changed files with 50 additions and 6 deletions
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue