diff options
author | 0neGal <mail@0negal.com> | 2021-12-28 18:16:46 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-28 18:23:46 +0100 |
commit | 8b90dc59f005ccb394f3392a80dcc28cc0ac73e7 (patch) | |
tree | 1d42e32c769bde9021876c55c165f524f8520710 /src/lang.js | |
parent | c7d3e7480395fa7e5cb0104c8c8efd87ecb6a1a4 (diff) | |
download | Viper-8b90dc59f005ccb394f3392a80dcc28cc0ac73e7.tar.gz Viper-8b90dc59f005ccb394f3392a80dcc28cc0ac73e7.zip |
if no lang is set, use "en"
By error I forgot to include this check... I also added in the ability
for it to look for a lang file without the extra locale info on the end,
i.e if "en-GB" is not found it'll try "en"
Diffstat (limited to 'src/lang.js')
-rw-r--r-- | src/lang.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lang.js b/src/lang.js index 4e4e481..266fb8b 100644 --- a/src/lang.js +++ b/src/lang.js @@ -1,10 +1,15 @@ const fs = require("fs"); -var lang = "en-US"; +var lang = "en"; if (fs.existsSync("viper.json")) { lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang; + if (! lang) {lang = "en"} if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) { - lang = "en-US"; + if (fs.existsSync(__dirname + `/lang/${lang.replace(/-.*$/, "")}.json`)) { + lang = lang.replace(/-.*$/, ""); + } else { + lang = "en"; + } } } |