Description
While implementing the prefixes for [locale] segment, I've found that the es-US locale (and probably other unsupported ISO 639-1 standard language codes locales, tho es-US is widely used) can't be prefixed. The routing object with supported locales and prefixes specified as localePrefix will respond with 404 in the middleware setup. Other defined locales in the config will be fine, they will be prefixed and server will respond with 200 HTTP code, except for es-US. It seems like it is replaced with the nearest ISO standard lang code resolved for the build environment. In this case, the response's NEXT_LOCALE cookie header will resolve to es-US -> en-US, which is wrong, I should be able to prefix all locales specified in my next-intl config. I believe createIntlMiddleware(routing) needs to be patched.
Verifications
Mandatory reproduction URL
https://github.com/karolkarolka/next-intl-es-us-prefix-bug
Reproduction description
Steps to reproduce:
- Open reproduction
- Navigate to
/us/es
- The server will respond with
GET /us/es 404
Expected behaviour
Expected behaviour:
es-US locale should be prefixed with /us/es. locale in getRequestConfig(async ({ locale }) should be es-US. The path /es/us should resolve to / home directory.
Actual behaviour:
es-US locale cannot be prefixed properly. locale in getRequestConfig(async ({ locale }) isen-US. The path /es/usresolves to 404 not found.
Description
While implementing the prefixes for
[locale]segment, I've found that thees-USlocale (and probably other unsupported ISO 639-1 standard language codes locales, thoes-USis widely used) can't be prefixed. Theroutingobject with supportedlocalesandprefixesspecified aslocalePrefixwill respond with 404 in the middleware setup. Other defined locales in the config will be fine, they will be prefixed and server will respond with 200 HTTP code, except fores-US. It seems like it is replaced with the nearest ISO standard lang code resolved for the build environment. In this case, the response'sNEXT_LOCALEcookie header will resolve toes-US->en-US, which is wrong, I should be able to prefix all locales specified in mynext-intlconfig. I believecreateIntlMiddleware(routing)needs to be patched.Verifications
Mandatory reproduction URL
https://github.com/karolkarolka/next-intl-es-us-prefix-bug
Reproduction description
Steps to reproduce:
/us/esGET /us/es 404Expected behaviour
Expected behaviour:
es-USlocale should be prefixed with/us/es.localeingetRequestConfig(async ({ locale })should bees-US. The path/es/usshould resolve to/home directory.Actual behaviour:
es-USlocale cannot be prefixed properly.localeingetRequestConfig(async ({ locale })isen-US. The path/es/usresolves to 404 not found.