[Next-Intl] My Language Selector Button only changes the locale segment of the dynamic routes
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
My Language Selector component only changes the locale segment when I switch the language to another language.
For example, if the current route is
For the "Static" locales the language selector seems to be working accordingly, however I need some help with making it work correctly for dynamic routes as well.
I've also created this video in order to better explain what happens currently, with a bit of context in regards to the code structure towards the end: https://youtu.be/X_Y4yEW7DYk
Here is the Next-Intl Documentation I've been trying to follow, but I'm not a programmer so I don't understand it that well:
https://next-intl-docs.vercel.app/docs/routing/navigation
https://next-intl-docs.vercel.app/docs/routing/middleware
Bellow you'll find the related code.
Language Selector: https://paste.ec/paste/AIMXTrkR#krqY8JgpJ08Zg0HOSHOfFnAZ9jFPLDdJ4atIUWBtREr
Top Navigation Bar Component:
https://paste.ec/paste/Xe3doGz1#IkZtlHQ-+9iID5/RK7sqOWBD1U+XIK2pSJTy8IGduDn
Navigation.ts:
https://paste.ec/paste/vOKpJy6t#XssSgAoqQNF8E+4fhl8mjc1B6GsTk+14O+xuSHFkyu0
Middleware.ts:
https://paste.ec/paste/xQl8fhnC#DuCcVEbZzenxgofdczSY2lo0XUT1EDkh6KBT2oAG2hl
i18n.ts:
https://paste.ec/paste/uoNKi0AO#6VJEiDWLfpgu8r3ilJ7SXRg3EVJeWpWo1se-ff7esW9
For example, if the current route is
/en/user/[id] and I try to switch to Romanian, instead of switching it /ro/utilizator/id it switches to /ro/user/id.For the "Static" locales the language selector seems to be working accordingly, however I need some help with making it work correctly for dynamic routes as well.
I've also created this video in order to better explain what happens currently, with a bit of context in regards to the code structure towards the end: https://youtu.be/X_Y4yEW7DYk
Here is the Next-Intl Documentation I've been trying to follow, but I'm not a programmer so I don't understand it that well:
https://next-intl-docs.vercel.app/docs/routing/navigation
https://next-intl-docs.vercel.app/docs/routing/middleware
Bellow you'll find the related code.
Language Selector: https://paste.ec/paste/AIMXTrkR#krqY8JgpJ08Zg0HOSHOfFnAZ9jFPLDdJ4atIUWBtREr
Top Navigation Bar Component:
https://paste.ec/paste/Xe3doGz1#IkZtlHQ-+9iID5/RK7sqOWBD1U+XIK2pSJTy8IGduDn
Navigation.ts:
https://paste.ec/paste/vOKpJy6t#XssSgAoqQNF8E+4fhl8mjc1B6GsTk+14O+xuSHFkyu0
Middleware.ts:
https://paste.ec/paste/xQl8fhnC#DuCcVEbZzenxgofdczSY2lo0XUT1EDkh6KBT2oAG2hl
i18n.ts:
https://paste.ec/paste/uoNKi0AO#6VJEiDWLfpgu8r3ilJ7SXRg3EVJeWpWo1se-ff7esW9