diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/langs.js | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/scripts/langs.js b/scripts/langs.js index e870a3c..a91b243 100644 --- a/scripts/langs.js +++ b/scripts/langs.js @@ -1,9 +1,35 @@ const fs = require("fs"); let problems = false; -let lang = require("../src/lang/en.json"); let maintainers = require("../src/lang/maintainers.json"); +function flatten_obj(data) { + var obj = {}; + + for (let i in data) { + if (! data.hasOwnProperty(i)) { + continue; + } + + if (typeof data[i] == "object" && data[i] !== null) { + var flattened = flatten_obj(data[i]); + for (var ii in flattened) { + if (! flattened.hasOwnProperty(ii)) { + continue; + } + + obj[i + "." + ii] = flattened[ii]; + } + } else { + obj[i] = data[i]; + } + } + + return obj; +} + +let lang = flatten_obj(require("../src/lang/en.json")); + langs = fs.readdirSync("src/lang") langs.forEach((localefile) => { if (localefile == "maintainers.json") {return} @@ -12,7 +38,7 @@ langs.forEach((localefile) => { let langmaintainers = maintainers.list[localefile.replace(/\..*$/, "")]; let locale = false; try { - locale = require("../src/lang/" + localefile) + locale = flatten_obj(require("../src/lang/" + localefile)); }catch(err) { console.log(`\x1b[101m!! ${localefile} is not formatted right !!\x1b[0m`); return |