From 08aa91d82b4ce1a77555f7d83d262d09d12ea385 Mon Sep 17 00:00:00 2001 From: lixian Date: Thu, 15 Apr 2021 09:24:01 +0800 Subject: [PATCH] Fix switch language error because of some strings not translation --- src/js/modules/tools/translate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/modules/tools/translate.js b/src/js/modules/tools/translate.js index b1aead2..e02190c 100644 --- a/src/js/modules/tools/translate.js +++ b/src/js/modules/tools/translate.js @@ -16,6 +16,7 @@ class Tools_translate_class { this.Helper = new Helper_class(); this.translations = {}; + this.trans_lang_codes = []; this.load_translations(); } @@ -34,9 +35,7 @@ class Tools_translate_class { this.Helper.setCookie('language', lang_code); } - var first = this.translations[Object.keys(this.translations)[0]]; - - if (first[lang_code] != undefined || lang_code == 'en') { + if (this.trans_lang_codes.includes(lang_code) || lang_code == 'en') { //translate $(element || 'body').translate({lang: lang_code, t: this.translations}); config.LANG = lang_code; @@ -62,6 +61,7 @@ class Tools_translate_class { } _this.translations[i][moduleKey] = classObj[i]; } + _this.trans_lang_codes.push(moduleKey); } }); }