Skip to content

Commit

Permalink
Fix translation paths (#672)
Browse files Browse the repository at this point in the history
* Fix translation paths

* Actually fix it
  • Loading branch information
ludeeus authored Jun 30, 2023
1 parent 0ef92e2 commit e380be5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions script/gulp/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function recursiveFlatten(prefix, data) {
...recursiveFlatten(prefix + key + ".", data[key]),
};
} else {
output[prefix + key] = data[key].replace(/'{/g, "''{").replace(/}'/g, "}''");
output[prefix + key] = String(data[key]).replace(/'{/g, "''{").replace(/}'/g, "}''");
}
});
return Object.fromEntries(Object.entries(output).sort());
Expand All @@ -37,21 +37,21 @@ gulp.task("generate-translations", async function (task) {
);

for (const language of fs.readdirSync(paths.translations_src)) {
if (ignoredLanguages.has(language)) continue;
const lang = language.split(".")[0];
const fileName = lang in changeLang ? changeLang[lang] : lang;
if (ignoredLanguages.has(language)) continue;
const fileName = `${lang in changeLang ? changeLang[lang] : lang}.json`;
const translation = { ...defaultTranslation };
if (language !== "en" && fs.existsSync(`${paths.translations_src}/${fileName}`)) {
if (lang !== "en" && fs.existsSync(`${paths.translations_src}/${language}`)) {
const fileTranslations = recursiveFlatten(
"",
fs.readJSONSync(`${paths.translations_src}/${fileName}`, "utf-8")
fs.readJSONSync(`${paths.translations_src}/${language}`, "utf-8")
);
for (const key of Object.keys(fileTranslations)) {
translation[key] = fileTranslations[key];
}
}
await fs.writeFile(
`${paths.build_dir}/translations/${language}`,
`${paths.build_dir}/translations/${fileName}`,
JSON.stringify(translation, null),
"utf-8"
);
Expand Down

0 comments on commit e380be5

Please sign in to comment.