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

Switching locales fails after clicking on localized anchor. #3343

Open
BroccoliBasti opened this issue Feb 3, 2025 · 4 comments
Open

Switching locales fails after clicking on localized anchor. #3343

BroccoliBasti opened this issue Feb 3, 2025 · 4 comments

Comments

@BroccoliBasti
Copy link

Environment



Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-bsxo89jd?file=pages%2Findex.vue

Describe the bug

If the id of an element is localized and an anchor is used to link to that element, the id appears in the URL. When switching locales the path is translated correctly, but the id is not translated at all. This means that on loading the new language, the page is trying to scroll to an id that no longer exists on the page, causing it to not scroll at all. In production the green and blue progression bar from Nuxt also appears at the top and never resolves.

Additional context

This problem is much more prevalent when using Nuxt i18n alongside Nuxt Content, since it automatically renders headers as anchors.

Logs

@valsaven
Copy link

valsaven commented Feb 4, 2025

Maybe this will help somehow: I encountered a similar issue - the keys in $t weren't being translated after changing the language.

So far, I've only understood that the problem is with the langDir parameter, and this started from version 9.1.2 and continues up to the latest version. If you specify the translation keys directly in the messages object within defineI18nConfig, everything works.
But if you place them in separate files, errors start occurring after changing the locale, like index.vue:6 [intlify] Not found 'home.p1' key in 'ja' locale messages.

@BobbieGoede
Copy link
Collaborator

@valsaven
Your issue sounds different than the one described, could you check if you're still experiencing the same behavior after installing the edge release with npm i -D @nuxtjs/i18n@npm:@nuxtjs/i18n-edge?

@valsaven
Copy link

valsaven commented Feb 4, 2025

@BobbieGoede Yes, I just checked, and the issue is reproducible: https://github.com/user-attachments/assets/114b0518-0280-493f-ad40-4c466ba558de

I thought it might have something to do with the problem described by the author of this issue. If it doesn't seem related, then to avoid spamming here, if I have time - I'll try to create a reproducible build of this error on https://stackblitz.com/ and open a new issue.

@davinma
Copy link

davinma commented Feb 13, 2025

see #3319 downgrading @nuxtjs/i18n to 9.1.1 work again.

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

4 participants