You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add a language switcher inside an existing navigation bar.
Everything works as expected except changing the locale.
When I click on the link, the emitted value I retrive is the lang (i.e 'en').
Now, how do I programmatically change the locale inside a function like this:
const navClick = (event, item) => {
alert(item.lang); // ok it return the locale 'en' clicked
useI18n().locale = item.lang; // it doesn't work
};
What do I need to import inside my <script setup>? import { useI18n } from "vue-i18n"; ?
Which function to use?
tested with useI18n().locale = 'en'; but it doesn't work
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to add a language switcher inside an existing navigation bar.
Everything works as expected except changing the locale.
When I click on the link, the emitted value I retrive is the lang (i.e 'en').
Now, how do I programmatically change the locale inside a function like this:
What do I need to import inside my
<script setup>
?import { useI18n } from "vue-i18n";
?Which function to use?
tested with
useI18n().locale = 'en';
but it doesn't workBeta Was this translation helpful? Give feedback.
All reactions