V-T directive not reactive with locale change
See original GitHub issueWhen we use the directive <span v-t="'path'"></span>
, translation is not reactive when the locale of i18n changed.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:7
Top Results From Across the Web
Custom directive localization | Vue I18n
When v-t directive is applied to an element inside <transition> component (opens new window), you may notice that the translated message ...
Read more >5 ways of displaying i18n translations in Vue
NB: This directive is not reactive, therefore the content needs to be manually reloaded when the locale changes.
Read more >How to bind attributes with v-bind only once? - Stack Overflow
$t('LOCALE.STRING') doesn't change unless your locale changes, you're guaranteed only a single run, after which the value will be cached by Vue ...
Read more >The Ultimate Guide to Vue Localization with Vue I18n - Medium
Our components react and re-render when our locale changes ... Vue I18n provides a Vue directive, v-t , that can be used to...
Read more >Legacy API - Vue I18n
The v-t directive for Vue 3 now preserves the default content. ... If this is used in a reactive context, it will re-evaluate...
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
@austi10 probably way too late, but to solve the reactivity problem you may just use
v-text
directive instead. Solution nr 5 here.I’m facing a similar problem that @ar53n mentioned above. I am using vuetify toolbar for representing a navbar. When I select a flag from the drop down menu of this navbar, the translations for the toolbar items are not performed for this component (which is not specified in the router view of the App component) alone, however the other components (which reside inside the router-view) are translated. I am using v-t directive. Although $t/$tc work fine, but I would rather prefer to use v-t directive due to its caching advantage in my application. Using object syntax for v-t directive works by specifying the locale as following
v-btn v-t=“‘{path: ‘Navbar.Option’, locale: this.$i18n.locale}’”
However I do not want to include locale property each and everytime into my HTML templates, which only includes redundancy