Kaynağa Gözat

Fixed bug in applocale.js

- Added check for this.localData undefine
- Updated version code
Toby Chui 5 ay önce
ebeveyn
işleme
8ca6ad9be6
2 değiştirilmiş dosya ile 5 ekleme ve 2 silme
  1. 1 1
      src/main.flags.go
  2. 4 1
      src/web/script/applocale.js

+ 1 - 1
src/main.flags.go

@@ -33,7 +33,7 @@ var subserviceBasePort = 12810            //Next subservice port
 
 // =========== SYSTEM BUILD INFORMATION ==============
 var build_version = "development"                      //System build flag, this can be either {development / production / stable}
-var internal_version = "0.2.021"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
+var internal_version = "0.2.022"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
 var deviceUUID string                                  //The device uuid of this host
 var deviceVendor = "IMUSLAB.INC"                       //Vendor of the system
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information

+ 4 - 1
src/web/script/applocale.js

@@ -72,7 +72,7 @@ function NewAppLocale() {
         translate: function(targetLang = "") {
             const lang = targetLang || this.lang;
             if (lang === 'en-us') return; // Don't translate English
-            if (!this.localData.keys?.[lang]) {
+            if (!this.localData || !this.localData.keys?.[lang]) {
                 console.warn(`[Applocale] failed to load language ${lang}, falling back to default`);
                 return;
             }
@@ -101,6 +101,9 @@ function NewAppLocale() {
         // API
         getString: function(key, original) {
             if (this.lang === 'en-us') return original; // Directly return original if English
+            if (!!this.localData ){
+                return original;
+            }
             return this.localData.keys[this.lang]?.strings?.[key] || original;
         }
     };