Locale property of useI18n seems as it is not Reactive
See original GitHub issueHi vue-i18n
authors,
I am working on Vue 3 project and trying to switch locale via URL i18n.locale=to.params.lang
. In the components where I am using ...useI18n()
inside the return of setup()
to retrievelocale
, but locale property does not change dynamically as expected.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Problem to use VueI18n outside a component - Stack Overflow
To use i18n with Vue 3's composition API, but outside a component's setup() , you can access its translation API (such as the...
Read more >Support Composition API · Issue #693 · kazupon/vue-i18n
But for i18n it seems like having to useI18n() in every component just ... @OrestHk - Since the i18n object isn't reactive, there's...
Read more >Composition API - Vue I18n
global property: VueI18n instance to Composer instance. You are now ready to use useI18n in the component setup . The code looks like...
Read more >The Ultimate Vue Localization Guide | Phrase
Let's refactor our LocaleSwitcher and LocalizedLink components to use the reactive locale property. src/components/l10n/LocaleSwitcher.vue.
Read more >The Ultimate Guide to Vue Localization with Vue I18n - Medium
The nice thing about VueI18n 's locale property is that it's read/write and reactive. So if we set a new value to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually in my app I use object destructuring, but for purpose of clarity I used
...useI18n()
in my aforementioned example. @ux-engineer Thank you for your advice.@YusufISMAILOGLU I’d advise against using this syntax:
This way you are exposing everything to the template when actually needing just one property. Instead consider using object-desctructed properties:
Also in some cases, you might need to wrap the returned property as ref, but I’m not yet sure when this is needed to be more specific…perhaps not helpful here: