From cbb66532ad2f26be1d595c9831b03465b06b9ee4 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Thu, 6 Apr 2023 12:12:50 +0800 Subject: [PATCH] fix: i18n fallback error --- src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 77fcd5a..9447ec5 100644 --- a/src/index.js +++ b/src/index.js @@ -31,11 +31,15 @@ class UniID { if (uniIDConfig.hasFile('custom-token.js')) { this.setInterceptor('customToken', require(uniIDConfig.resolve('custom-token.js'))) } + const fallbackLocale = 'zh-Hans' this._i18n = uniCloud.initI18n({ locale: this._clientInfo.locale, - fallbackLocale: 'zh-Hans', - messages + fallbackLocale, + messages: JSON.parse(JSON.stringify(messages)) }) + if (!messages[this._i18n.locale]) { + this._i18n.setLocale(fallbackLocale) + } } setInterceptor (timing, handler) { -- GitLab