mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Add fallback to English US if language doesn't exist
This commit is contained in:
parent
ade35473a8
commit
994ab5f5b0
1 changed files with 4 additions and 1 deletions
|
@ -130,7 +130,10 @@ export async function getLang(object: string) {
|
||||||
if (language.length == 2) {
|
if (language.length == 2) {
|
||||||
language = language + "-" + language.toUpperCase();
|
language = language + "-" + language.toUpperCase();
|
||||||
}
|
}
|
||||||
const langPath = path.join(__dirname, "../", "/assets/lang/" + language + ".json");
|
var langPath = path.join(__dirname, "../", "/assets/lang/" + language + ".json");
|
||||||
|
if (!fs.existsSync(langPath)) {
|
||||||
|
langPath = path.join(__dirname, "../", "/assets/lang/en-US.json");
|
||||||
|
}
|
||||||
let rawdata = fs.readFileSync(langPath, "utf-8");
|
let rawdata = fs.readFileSync(langPath, "utf-8");
|
||||||
let parsed = JSON.parse(rawdata);
|
let parsed = JSON.parse(rawdata);
|
||||||
return parsed[object];
|
return parsed[object];
|
||||||
|
|
Loading…
Reference in a new issue