Child routes have no language prefix for non default languages

popescuandrei9mai
0
popescuandrei9mai
commented 3 months ago

Version

5.12.7

Reproduction link

https://codesandbox.io/s/codesandbox-nuxt-mpc6k

Steps to reproduce

Press the Child 1 button from home page. Switch the language to English.

What is expected ?

Route should change from '/despre/primul-copil' to '/en/about/first-child'

What is actually happening?

Route changes from '/despre/primul-copil' to '/about/first-child'

Additional comments?

Note that the default language is romanian so child routes for english should get the '/en' prefix.
The problem seems to come from this line https://github.com/nuxt-community/nuxt-i18n/blob/master/src/helpers/routes.js#L116

bug
0
woutercouvaras
5
woutercouvaras
commented 3 months ago

Hi @popescuandrei9mai, I did you checkout the code sanbox example here:

https://nuxtjs.org/examples/i18n#official-code-i18n-module-code-

The plugin and middleware files have some details around redirecting…it seems they redirect the local not to have a prefix, but if you want one, I would imagine you could use the same sort of logic to redirect to the default prefix if that's the behaviour you're after?

0
popescuandrei9mai
0
popescuandrei9mai
commented 3 months ago

Hi @woutercouvaras. This can be a fix for the issue but it looks more like a workaround. There should be no difference between parent and child routes regarding the prefix.

0
Informations
Bug ReportOpen
#c259 - Created 3 months ago