I am trying to set up localization for my Nuxt frontend. Every time I switch to English and then move to an other subpage of my website it does reset back to German.
This is my LanguageSelector
<template>
<div class="lang-dropdown">
<select v-model="$i18n.locale">
<option
v-for="lang in $i18n.locales"
:key="lang.code"
:value="lang.code"
onchange="changeLocale"
>
{{ lang.name }}
</option>
</select>
</div>
</template>
This is my i18n config file
import de from '../locales/de.json'
import en from '../locales/en.json'
export default {
local: 'en',
fallbackLocale: 'de',
messages: { de, en },
strategy: 'prefix'
}
This is my buildModules section of the Nuxt.config.js
['nuxt-i18n',
{
defaultLocale: 'de',
seo: true,
locales: [
{
code: 'de',
name: 'Deutsch',
iso: 'de-DE'
},
{
code: 'en',
name: 'English',
iso: 'en-US'
}
],
vueI18n: i18n
}]
question from:
https://stackoverflow.com/questions/65864526/locale-keeps-resetting-between-switching-pages-nuxt-i18n 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…