mirror of
https://github.com/ivabus/gui
synced 2025-04-24 06:27:09 +03:00

* #241 init crowdin usage * #241 convert all convertible copy into i18n value --------- Co-authored-by: neil <neil@neils-MacBook-Pro.local>
39 lines
1 KiB
JavaScript
39 lines
1 KiB
JavaScript
const otaClient = require("@crowdin/ota-client");
|
|
const _ = require("lodash");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
// this read only hash is from crowdin
|
|
const hash = "cf849610ca66250f0954379ct4t";
|
|
|
|
const client = new otaClient.default(hash);
|
|
|
|
async function main() {
|
|
console.log("getting latest translation!");
|
|
const [languagesList, translationsRaw] = await Promise.all([
|
|
client.getLanguageObjects(),
|
|
client.getStrings()
|
|
]);
|
|
|
|
const lang = languagesList.reduce((map, lang) => {
|
|
map[lang.id] = lang.name;
|
|
return map;
|
|
}, {});
|
|
|
|
const translations = languagesList.reduce((map, langRaw) => {
|
|
map[langRaw.id] = {
|
|
lang
|
|
};
|
|
const translation = translationsRaw[langRaw.id];
|
|
for (const k in translation) {
|
|
const key = [langRaw.id, k].join(".");
|
|
_.set(map, key, translation[k]);
|
|
}
|
|
return map;
|
|
}, {});
|
|
|
|
const translationsPath = path.join(__dirname, "../src/libs/translations/translations.json");
|
|
await fs.writeFileSync(translationsPath, JSON.stringify(translations, null, 2), "utf-8");
|
|
}
|
|
|
|
main();
|