Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n多语言 #1295

Closed
lydiaWang1918 opened this issue Oct 18, 2023 · 1 comment
Closed

i18n多语言 #1295

lydiaWang1918 opened this issue Oct 18, 2023 · 1 comment

Comments

@lydiaWang1918
Copy link

问题描述:
项目开启i18n,通过模块路径传入语言集,在A页面将中文切换成英文,跳到B页面,打印this.$i18n.locale为“en-US”,但是this.$t()获取的还是中文,同样的方式在B页面切换中英文,返回到A页面,A页面能正常显示

项目配置:
new MpxWebpackPlugin({ i18n: { locale: 'zh-CN', messagesPath: path.resolve(__dirname, '../src/common/locales/i18n.js') } })

// i18n
module.exports = { 'zh-CN': { message: { hello: '{msg} 世界' }, welcome: { intro: '这是mpx框架提供的i18n能力演示用的小程序' } }, 'en-US': { message: { hello: '{msg} world' }, welcome: { intro: 'this is an example of using i18n with mpx framework' } } }

// 使用
changeLang() { this.language = this.language === 'en-US' ? 'zh-CN' : 'en-US' mpx.i18n.locale = this.language },

@CommanderXL
Copy link
Member

@mpxjs/core@2.8.47@mpxjs/webpack-plugin@2.8.47 版本以及最新版本 @mpxjs/core@2.8.53@mpxjs/webpack-plugin@2.8.53 均未复现问题。

视项目情况来手动升级核心依赖包或通过脚手架创建新项目确保依赖包为最新。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants