aboutsummaryrefslogtreecommitdiff
path: root/src/lang.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2021-12-29 00:58:35 +0100
committer0neGal <mail@0negal.com>2021-12-29 00:58:35 +0100
commit34cf8cbd3afb57d279f4acfb6f2f891e974137bd (patch)
tree63fe9d5eca4b8309716606632629a9838f20237a /src/lang.js
parentefdc25e4516bc5341e305acf42935407f465a0fb (diff)
downloadViper-34cf8cbd3afb57d279f4acfb6f2f891e974137bd.tar.gz
Viper-34cf8cbd3afb57d279f4acfb6f2f891e974137bd.zip
fallback to localizations
If a message is not localized it'll default back to English, instead of just giving back the string...
Diffstat (limited to 'src/lang.js')
-rw-r--r--src/lang.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lang.js b/src/lang.js
index 266fb8b..d404e8e 100644
--- a/src/lang.js
+++ b/src/lang.js
@@ -1,6 +1,7 @@
const fs = require("fs");
var lang = "en";
+var langDef = JSON.parse(fs.readFileSync(__dirname + `/lang/en.json`, "utf8"));
if (fs.existsSync("viper.json")) {
lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang;
if (! lang) {lang = "en"}
@@ -19,6 +20,10 @@ module.exports = (string) => {
if (langObj[string]) {
return langObj[string];
} else {
- return string
+ if (langDef[string]) {
+ return langDef[string];
+ } else {
+ return string;
+ }
}
}