-
-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V-T directive not reactive with locale change #227
Comments
I've found that it works when explicitly setting the locale in the binding, something like:
Updated fiddle example: https://jsfiddle.net/70ruLmdx/2/ However, I'm not sure about the performance impact, i.e. if this version would still perform better than using |
@DorianGrey write too long this way. |
I have problem when in component only directives. Sidebar is named router-view. My sidebar not translated when i change language. <template>
<el-menu :router="true">
<el-menu-item index="" @click="back()">
<template slot="title">
<i class="el-icon-arrow-left"></i>
<span v-t="'common.back'"></span>
</template>
</el-menu-item>
<el-menu-item index="1" :route="{name: 'Account'}" v-t="'common.summaryInfo'"></el-menu-item>
<el-menu-item index="2" :route="{name: 'EventLog'}" v-t="'common.eventLog'">
</el-menu-item>
</el-menu>
</template>
<script>
export default {
name: 'ProfileSidebarMenu',
data() {
return {
backUrl: ''
};
},
beforeRouteEnter(to, from, next) {
},
methods: {
back() {
}
}
};
</script> |
@ar53n
Without This works for me also in combination with sidebars, dialogs v-if, v-show etc. |
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. 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 |
This bug is still active, not sure why the issue is closed |
Hi, I'm encountering the same issue with vue(3.4.15), vuei-18n(9.9.1), vuetify(3.5.2). With these versions, v-t directives are not updated when the language(locale) change is realized from another component. After playing a bit with interpollation and directives, I have observed that interpollation is always updated and react on any changes of the locale. But v-t directives were updated only on the next change of the same component. As workaround, I have added something in the component using v-t directives in order to detect that locale is changing (it forces re-rendering of the component):
Once it's in place, if I have added an interpollation in the template, then v-t is well updated too.
change(locale) -> changer(url) -> wait a change in components to trigger re-rendering of v-t -> nextTick() -> re-render with good translation. So unfortunately, without any other solution, I have added at least an invisible interpolation of the locale value in the template My understanding is that v-t directives do not react by principle to any changes in background, so we have to handle it by watching the locale value (only), otherwise we have to use interpollation. Thanks you. Ps: For vue2, the concept would be similar by watching the "this.$i18n.locale" as it is mentioned by DorianGrey (and Austin10). |
When we use the directive
<span v-t="'path'"></span>
, translation is not reactive when the locale of i18n changed.Fiddle example
The text was updated successfully, but these errors were encountered: