mirror of
https://github.com/MultiMote/niimbluelib.git
synced 2025-03-17 20:11:01 +03:00
24 lines
787 B
JavaScript
24 lines
787 B
JavaScript
const locale = (
|
|
await (await fetch("https://oss-print.niimbot.com/public_resources/static_resources/languagePack/en.json")).json()
|
|
)["lang"];
|
|
|
|
const translateDeep = (obj) => {
|
|
if (typeof obj === "object") {
|
|
for (const key in obj) {
|
|
if (typeof obj[key] === "object") {
|
|
translateDeep(obj[key]);
|
|
} else if (typeof obj[key] === "string" && key === "multilingualCode") {
|
|
const translated = locale[obj[key]];
|
|
obj["translated"] = translated ? translated["value"] : "TRANSLATION_NOT_FOUND";
|
|
}
|
|
}
|
|
}
|
|
return obj;
|
|
};
|
|
|
|
const devices = await (await fetch("https://oss-print.niimbot.com/public_resources/static_resources/devices.json")).json();
|
|
|
|
const translated = devices.map(translateDeep);
|
|
|
|
console.log(JSON.stringify(translated, null, 2));
|