When switching languages, the data reactive is lost
See original GitHub issueReporting a bug?
“vue-i18n”: “9.2.0-beta.13” When switching languages, the data reactive is lost, 9.2.0-beta.11 version didn’t have this problem!
Expected behavior
I hope I don’t lose the responsiveness
Reproduction
import { createI18n } from ‘vue-i18n’;
import enDesign from ‘@jiaozhiye/qm-design/lib/locale/lang/en’; import zhDesign from ‘@jiaozhiye/qm-design/lib/locale/lang/zh-cn’;
import enLocale from ‘./lang/en’; import zhLocale from ‘./lang/zh-cn’;
const messages = { [enLocale.name]: { qm: enDesign.qm, app: enLocale.app, }, [zhLocale.name]: { qm: zhDesign.qm, app: zhLocale.app, }, };
const i18n = createI18n({ locale: ‘zh-cn’, fallbackLocale: ‘zh-cn’, messages, });
const { t, mergeLocaleMessage } = i18n.global;
const changeLocale = (lang: string): void => { i18n.global.locale = lang; };
export { t, mergeLocaleMessage, changeLocale }; export default i18n;
// ==============
By calling the changeLocale function to achieve language switch, unfortunately, it didn’t have the desired effect.
System Info
"vue": "^3.2.20",
"vue-i18n": "^9.2.0-beta.13",
Screenshot
No response
Additional context
No response
Validations
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:14 (6 by maintainers)
Top GitHub Comments
I’ve just released v9.2.0-beta.14 ! https://github.com/intlify/vue-i18n-next/releases/tag/v9.2.0-beta.14
Please check it! Thanks all!
@zynth17 I just checked, it’s caused by #736. In short, when you use vue-i18n@9.2.0-beta.13, you will use vue-i18n.esm-browser.prod.js which has a tree-shaking issue.
vue-i18n-next has fixed # 736 in #754, but no new version has been released yet.
@kazupon I think we should release a new version from repo. WDYT?