add translateable strings and allow overriding of english strings (#158)

This commit is contained in:
Ricky Vetter 2017-10-23 15:01:26 -07:00 committed by Joel Marcey
parent 65a5e02ec2
commit 58613545b6
2 changed files with 35 additions and 2 deletions

View file

@ -20,6 +20,14 @@ const babylon = require("babylon");
const traverse = require("babel-traverse").default;
const sidebars = require(CWD + "/sidebars.json");
let currentTranslations = {
"localized-strings": {},
"pages-strings": {}
};
if (fs.existsSync(path)) {
currentTranslations = JSON.parse(fs.readFileSync(CWD + "/i18n/en.json", "utf8"));
}
function writeFileAndCreateFolder(file, content) {
mkdirp.sync(file.replace(new RegExp("/[^/]*$"), ""));
fs.writeFileSync(file, content);
@ -121,6 +129,22 @@ function execute() {
"Help Translate|recruit community translators for your project"
] =
"Help Translate";
translations["pages-strings"][
"Edit this Doc|recruitment message asking to edit the doc source"
] =
"Edit";
translations["pages-strings"][
"Translate this Doc|recruitment message asking to translate the docs"
] =
"Translate";
translations["pages-strings"] = Object.assign(
translations["pages-strings"],
currentTranslations["pages-strings"],
);
translations["localized-strings"] = Object.assign(
translations["localized-strings"],
currentTranslations["localized-strings"],
);
writeFileAndCreateFolder(
CWD + "/i18n/en.json",
JSON.stringify(translations, null, 2)