question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

V-T directive not reactive with locale change

See original GitHub issue

When we use the directive <span v-t="'path'"></span> , translation is not reactive when the locale of i18n changed.

Fiddle example

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

2reactions
anzujcommented, Jul 14, 2020

@austi10 probably way too late, but to solve the reactivity problem you may just use v-text directive instead. Solution nr 5 here.

1reaction
austi10commented, May 27, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found