nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

useLocaleHead doesn't change or its not reactive from 8.0.1 version. #2771

Closed jesspinklet closed 9 months ago

jesspinklet commented 9 months ago

Environment


Reproduction

Here is the reproduction: I have changed the direction of japanese lang to rtl for testing

version 8.1.0 https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-cpbimm?file=components%2FLangSwitcher.vue

version 8.0.1 https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-td21q6?file=components%2FLangSwitcher.vue

version 8.0.0 https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-9rzhrz?file=components%2FLangSwitcher.vue

Describe the bug

image I have this in my app.vue file

after upgrading to 8.0.1 or anything else above from 8.0.0 version, the lang and dir attribute is not getting updated when i set locale from useI18n() unless I change page.

I read the docs and change logs but not sure if am I missing something or not

Additional context

No response

Logs

No response

BobbieGoede commented 9 months ago

You should switch locale using either setLocale from useI18n() or by navigating with switchLocalePath, setting locale directly may be fine when just using vue-i18n but we only document language switching using setLocale or switchLocalePath as this triggers more than just changing translations (as you have noticed).

This may seem to work in earlier versions, but what's really happening is that the head tags and language are not matching the page URL, which is not desirable behaviour.