release: v3.0.0-alpha-3060420220922001
调试过程如下
console.log(uni.getLocale()) // zh-Hans uni.setLocale('en') console.log(uni.getLocale()) // zh-Hans
console.log(uni.getLocale()) // zh-Hans
uni.setLocale('en')
如果在manifest.json中配置 locale: en , 仍打印出zh-Hans
locale: en
v8wbuo2f1#
uni-i18n/uni-i18n.es.js 里面的一段源码
uni-i18n/uni-i18n.es.js
function getDefaultLocale() { if (typeof uni !== 'undefined' && uni.getLocale) { return uni.getLocale(); } // 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale if (typeof global !== 'undefined' && global.getLocale) { return global.getLocale(); } return LOCALE_EN;}
function getDefaultLocale() {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if (typeof global !== 'undefined' && global.getLocale) {
return global.getLocale();
return LOCALE_EN;
所以小程序平台uni.setLocale('en')无效,这个文档里也没说明,真的坑!!!!
1条答案
按热度按时间v8wbuo2f1#
uni-i18n/uni-i18n.es.js
里面的一段源码所以小程序平台uni.setLocale('en')无效,这个文档里也没说明,真的坑!!!!