aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-09-16 01:28:38 +0200
committer0neGal <mail@0negal.com>2023-09-16 01:28:38 +0200
commita91f0d2eac46510c109a4faebf520f68a3456aab (patch)
tree66fffa7ea3d8fd1ce097424602d2c428cb4ce8be /scripts
parentba64cef4fd5738e5744814bf67dddbd3865132f1 (diff)
downloadViper-a91f0d2eac46510c109a4faebf520f68a3456aab.tar.gz
Viper-a91f0d2eac46510c109a4faebf520f68a3456aab.zip
lang files can now use objects!
The `lang()` function doesn't change whatsoever, as the lang files are flattened and are therefore identical to the before this commit. I also cleaned up the files, and all the lang files should now all look far more similar in order.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/langs.js30
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