Next.js Discord

Discord Forum

Link component does not automatically keep the same language when switching pages in app directory

Unanswered
Dwarf Crocodile posted this in #help-forum
Open in Discord
Dwarf CrocodileOP
Hey, has anybody an Solution fit Thiago Problem? (https://github.com/vercel/next.js/issues/54880)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/leosollereder/nextI18n

To Reproduce

To reproduce the bug, you need to follow the official documentation on i18n in the app router:

https://nextjs.org/docs/app/building-your-application/routing/internationalization

Describe the Bug

The code uses two different languages, "en" and "de", with "de" being the defaultLanguage.
When switching the language to english, and then using a component to another page, in the above case "/testsite", it leads me to the "/de/testsite" page, instead of keeping the english version.
Is this the expected/desired behaviour, and do I manually need to add the language to each href in the components for this to work?

Expected Behavior

The expected behaviour would be, that upon enabling localization, the language stays the same, even when switching pages, without having to manually add it at the beginning of a href of a .

0 Replies