Add fallback to English US if language doesn't exist

This commit is contained in:
smartfrigde 2022-06-12 13:32:46 +02:00
parent ade35473a8
commit 994ab5f5b0

View file

@ -130,7 +130,10 @@ export async function getLang(object: string) {
if (language.length == 2) {
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 parsed = JSON.parse(rawdata);
return parsed[object];