fix: fix custom l18n

This commit is contained in:
Tsubasa6848
2024-03-24 17:47:07 +08:00
Unverified
parent 42bd769d5c
commit 3488c812e3
+15 -4
View File
@@ -709,17 +709,28 @@ class JsonLanguage extends JsonConfig {
class JsonI18n {
constructor(path, localLangCode = "en_US") {
if (!path.endsWith("/") && !path.endsWith("\\")) {
path = path + "/";
}
this.mPath = path;
this.mLangCode = localLangCode;
this.mAllLanguages = {};
this.mDefaultLangCode = "en_US"
this.mDefaultLangCode = "en_US";
this.loadAllLanguages();
}
loadAllLanguages() {
let exist_list = File.getFilesList(this.mPath);
exist_list.forEach((name) => {
let code = name.replace(".json", "");
let path = this.mPath + name;
let language = new JsonLanguage(path);
this.mAllLanguages[code] = language;
});
}
loadLanguage(langCode, defaultData = {}) {
let langPath = this.mPath;
if (!langPath.endsWith("/") && !langPath.endsWith("\\")) {
langPath = langPath + "/";
}
langPath = langPath + langCode + ".json";
let language = new JsonLanguage(langPath, defaultData);
this.mAllLanguages[langCode] = language;