Nuxt i18n load language from cookie
I have the exact same problem than the person in this thread: https://stackoverflow.com/questions/71998762/change-nuxt-i18n-locale-with-cookie-on-site-load
I want to use Nuxt i18n, make it save the current locale on change when calling
setLocale
or setLocaleCookie
(in a cookie or anywhere), and load it back again on a page reload.
Unfortunately, every time I reload the page, the apps keeps using the default value set in defineI18nConfig({locale})
(in i18n.config.ts), the cookie is set back to the default value as well.
I do NOT want to use URL based locale. I'm using all default config values.
What did I do wrong?Stack Overflow
Change nuxt-i18n locale with cookie on site load
I've two locale; "fa" and "en" with fa being default. I've tried to change it with the following code block both on nuxtServerInit and fetch hook of layout but it still revert b...
1 Reply
found out i had to add a locales key to my nuxt.config i18n: {
strategy: 'no_prefix',
locales: ['en', 'fr']
},