mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Update translation script
This commit is contained in:
parent
a0fb5b861c
commit
1a91963732
@ -3,7 +3,6 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const matchAll = require("match-all");
|
const matchAll = require("match-all");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const YAWN = require("yawn-yaml/cjs");
|
|
||||||
const YAML = require("yaml");
|
const YAML = require("yaml");
|
||||||
|
|
||||||
const files = fs
|
const files = fs
|
||||||
@ -55,8 +54,6 @@ function match(originalObj, translatedObj, path = "/") {
|
|||||||
} else {
|
} else {
|
||||||
console.warn(" | Unknown type: ", typeof valueOriginal);
|
console.warn(" | Unknown type: ", typeof valueOriginal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const matching = translatedObj[key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in translatedObj) {
|
for (const key in translatedObj) {
|
||||||
@ -71,12 +68,14 @@ for (let i = 0; i < files.length; ++i) {
|
|||||||
const filePath = path.join(__dirname, "translations", files[i]);
|
const filePath = path.join(__dirname, "translations", files[i]);
|
||||||
console.log("Processing", files[i]);
|
console.log("Processing", files[i]);
|
||||||
const translatedContents = fs.readFileSync(filePath).toString("utf-8");
|
const translatedContents = fs.readFileSync(filePath).toString("utf-8");
|
||||||
const translated = YAML.parse(translatedContents);
|
|
||||||
const handle = new YAWN(translatedContents);
|
|
||||||
|
|
||||||
const json = handle.json;
|
const json = YAML.parse(translatedContents);
|
||||||
match(original, json, "/");
|
match(original, json, "/");
|
||||||
handle.json = json;
|
|
||||||
|
|
||||||
fs.writeFileSync(filePath, handle.yaml, "utf-8");
|
const stringified = YAML.stringify(json, {
|
||||||
|
indent: 4,
|
||||||
|
simpleKeys: true,
|
||||||
|
});
|
||||||
|
fs.writeFileSync(filePath, stringified, "utf-8");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user