aboutsummaryrefslogtreecommitdiff
path: root/src/lang.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-04-13 22:38:18 +0200
committer0neGal <mail@0negal.com>2022-04-13 22:39:19 +0200
commitb0e0e919ee5d94a3a0d935018f08d3b0fa603245 (patch)
tree9dafbfd6e01f761323934e813c611fd628a4c1c0 /src/lang.js
parent476c421b1ebf594b375ebdc53bb60a30c9a78e3c (diff)
downloadViper-b0e0e919ee5d94a3a0d935018f08d3b0fa603245.tar.gz
Viper-b0e0e919ee5d94a3a0d935018f08d3b0fa603245.zip
the user can now manually select a language
This allows someone to have their system in any language, and then have Viper in a separate language. This is also useful for testing.
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"));
}