I18n-module: onlyOnRoot not redirecting based on cookie in static target

Created on 10 Sep 2020  路  3Comments  路  Source: nuxt-community/i18n-module

Version

nuxt-i18n: 6.15.0
nuxt: 2.14.4

Nuxt configuration

mode:

  • [x] universal (static)

Nuxt-i18n configuration

i18n: {
    strategy: 'prefix',
    detectBrowserLanguage: {
      useCookie: true,
      alwaysRedirect: true,
      onlyOnRoot: true
    },
}

Reproduction Link

Demo: http://silent-watch.surge.sh/ru
Github: https://github.com/divine/i18n-static-redirect

It works on CodeSandbox because they don't support static target and runs in dev mode.

Steps to reproduce

When locale is changed cookie is being changed.

However on root path with onlyOnRoot option doesn't redirect based on stored cookie.

What is Expected?

When visiting https://silent-watch.surge.sh/ru going back to https://successful-direction.surge.sh should redirect to ru.

What is actually happening?

Redirection to /en

bug 馃悰

Most helpful comment

Fix released in v6.15.1

All 3 comments

Right, so it should redirect before updating the cookie in this case.

It's the #805 fix that doesn't play well with the latest changes.

The #805 is creating a redirect route from / to the default locale. I think I can just change that from a redirect route to a normal route. It should still trigger redirect but wouldn't force it to redirect to specific (default) locale.

Fix released in v6.15.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oanstein picture oanstein  路  3Comments

NadhirBoukhenifra picture NadhirBoukhenifra  路  4Comments

martinrisseeuw picture martinrisseeuw  路  6Comments

golubvladimir picture golubvladimir  路  4Comments

adi-zz picture adi-zz  路  4Comments