Add fallback to English

This commit is contained in:
smartfrigde 2022-06-17 09:37:18 +02:00
parent a216475618
commit 9efce82462

View file

@ -119,12 +119,17 @@ export async function setLang(language: string) {
var language: string;
export async function getLang(object: string) {
if (language == undefined) {
try {
const userDataPath = app.getPath("userData");
const storagePath = path.join(userDataPath, "/storage/");
const langConfigFile = storagePath + "lang.json";
let rawdata = fs.readFileSync(langConfigFile, "utf-8");
let parsed = JSON.parse(rawdata);
language = parsed["lang"];
} catch (e) {
console.log("Language config file doesn't exist. Fallback to English.")
language = "en-US"
}
}
if (language.length == 2) {
language = language + "-" + language.toUpperCase();