diff --git a/src/index.js b/src/index.js index 77fcd5a8d161b291842eb94cd9df749014d6edb8..9447ec5fffe7b9e70c93d5b64eebff73b93e744a 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) {