I use nuxt-i18n nuxt-i18n documentation link to get different locales on my website like that :
<nuxt-link v-for="locale in $i18n.locales"
v-if="locale.code !== $i18n.locale"
:key="locale.code"
:to="switchLocalePath(locale.code)"
class="locales white--text"
>{{ locale.code }}
</nuxt-link>
And it works perfectly fine but i want to transform this code to render in a select element:
<select v-model="selected" class="locales white--text" @change=" ??? ">
<option disabled value="">{{ $i18n.locale }}</option>
<option v-for="locale in $i18n.locales" :key="locale.code">{{ locale.code }}</option>
</select>
Locales strings appears well but i don't dind a solution to launch the switchLocalePath function on change. Is there a proper way to do that with nuxt (vue.js) ?
this.$router.push(this.switchLocalePath(locale.code));
– Groryselected
value instead (in @change handler). – Groryselected
(model) in your@change
function, as it's the only thing available onselect
level;locale.code
is property of correspondingoption
element. – Groryhttp://localhost:3000/
? For me the switcher works only in this case, but when I have nested roots in my Nuxt application, the switcher does not work. Do you have an idea why? I have posted a question about it – Cincture