Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] i18n translation not working correctly after browser language detection and redirect #3262

Open
xdkaka opened this issue Dec 9, 2024 · 1 comment

Comments

@xdkaka
Copy link

xdkaka commented Dec 9, 2024

Environment


  • Operating System: Darwin
  • Node Version: v20.11.0
  • Nuxt Version: 3.14.1592
  • CLI Version: 3.16.0
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: default
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

https://github.com/xdkaka/test-nuxt

Describe the bug

Description

After deploying to production, when detecting browser language and redirecting, some i18n translations don't update properly until page refresh.

Steps to Reproduce

  1. Visit http://localhost
  2. Auto-redirects to http://localhost/zh-CN based on browser language
  3. Some translations remain in initial language instead of target language
  4. Refreshing page at http://localhost/zh-CN fixes the issue

Expected Behavior

All translations should update to target language immediately after redirect.

Actual Behavior

  • Working:

    {{ $t('test') }}
  • Not Working:

    <div v-text="$t('test')"></div>
    <div v-html="$t('test')"></div>
    <input :placeholder="$t('test')">

Error Message

CG-eFvx0.js:14 Hydration completed but contains mismatches.

Environment

  • Nuxt 3
  • @nuxtjs/i18n v9
  • Production environment

Quick Setup

yarn build-prod && docker-compose down && docker-compose up -d

Additional Context

  • Only occurs after language detection and redirect
  • Works correctly after page refresh
  • SSR hydration mismatch error present

Additional context

No response

Logs

Hydration completed but contains mismatches

Additional context

No response

Logs

@ptdev
Copy link

ptdev commented Dec 12, 2024

Hi,

We're also experiencing redirection issues when using the latest v9.1.1 with the language autodetection and cookie redirection so something definitely got broken in this latest version.

Didn't open a new issue as it seems this will probably be the same.

On a larger project we're developing, once we switch to some other language than the default, then we can't change it back to the default.

Unfortunately I cannot replicate this exact behavior on a stackblitz reproduction.

But I did prepare a repro where you can definitely see weird behavior on the redirect cookies like duplicate cookies, cookies named "undefined", cookies with a date on the name, etc (see screenshot)

Image

Repro Link:

https://stackblitz.com/edit/nuxt-starter-smvxrq?file=nuxt.config.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants