mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Add fallback to English
This commit is contained in:
parent
a216475618
commit
9efce82462
1 changed files with 11 additions and 6 deletions
17
src/utils.ts
17
src/utils.ts
|
@ -119,12 +119,17 @@ export async function setLang(language: string) {
|
||||||
var language: string;
|
var language: string;
|
||||||
export async function getLang(object: string) {
|
export async function getLang(object: string) {
|
||||||
if (language == undefined) {
|
if (language == undefined) {
|
||||||
const userDataPath = app.getPath("userData");
|
try {
|
||||||
const storagePath = path.join(userDataPath, "/storage/");
|
const userDataPath = app.getPath("userData");
|
||||||
const langConfigFile = storagePath + "lang.json";
|
const storagePath = path.join(userDataPath, "/storage/");
|
||||||
let rawdata = fs.readFileSync(langConfigFile, "utf-8");
|
const langConfigFile = storagePath + "lang.json";
|
||||||
let parsed = JSON.parse(rawdata);
|
let rawdata = fs.readFileSync(langConfigFile, "utf-8");
|
||||||
language = parsed["lang"];
|
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) {
|
if (language.length == 2) {
|
||||||
language = language + "-" + language.toUpperCase();
|
language = language + "-" + language.toUpperCase();
|
||||||
|
|
Loading…
Reference in a new issue