aboutsummaryrefslogtreecommitdiff
path: root/src/lang.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lang.js')
-rw-r--r--src/lang.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lang.js b/src/lang.js
index 8174174..041ef35 100644
--- a/src/lang.js
+++ b/src/lang.js
@@ -7,8 +7,16 @@ var langObj = {};
function _loadTranslation() {
if (fs.existsSync("viper.json")) {
- lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang;
+ opts = JSON.parse(fs.readFileSync("viper.json", "utf8"));
+ lang = opts.lang;
+
if (! lang) {lang = "en"}
+
+ if (opts.autolang == false) {
+ lang = opts.forcedlang;
+ if (! lang) {lang = "en"}
+ }
+
if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) {
if (fs.existsSync(__dirname + `/lang/${lang.replace(/-.*$/, "")}.json`)) {
lang = lang.replace(/-.*$/, "");
@@ -19,6 +27,7 @@ function _loadTranslation() {
} else {
lang = "en";
}
+
langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8"));
}