Open DerZade opened 2 weeks ago
Thank you for your reporting!
Hmm.
vue-i18n does not seem to work v-t
on legacy mode, currently.
you can avoid composition mode.
https://stackblitz.com/edit/vitejs-vite-gdnzpe?file=src%2FApp.vue,src%2Fmain.js
Legacy mode will be removed in future versions of vue-i18n. I recommend you will use composition mode.
Reporting a bug?
v-t
directive does not update when locale switchesExpected behavior
Changing the locale updates all references of
v-t
Reproduction
Stackblitz: https://stackblitz.com/edit/vitejs-vite-3sfn11?file=src%2FApp.vue
GitHub Repo: https://github.com/DerZade/vue-i18n-locale-switching-bug-report
System Info
Screenshot
No response
Additional context
I started investigating this and found that apparently the composer of the
v-t
in my example is not the global composer (I don't know why tho, since there is only one instance in the whole app), therefore the watcher for the locale isn't added in the register hook of the directive:https://github.com/intlify/vue-i18n/blob/43072e83fe185c977424c7a0690ae0d3963a1185/packages/vue-i18n-core/src/directive.ts#L102-L107
Really dumb question: Why can't we just always add the watcher, why does it only work for the global instance?
Validations