How can I detect the default locale based on the URL when using localePrefix = 'as-needed' #876
Unanswered
staffanmowitz
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Sure: |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on a project that involves two languages: Swedish and English. I am using prefix-based routing with
localePrefix
set to as-needed
, where Swedish is the default language. When manually switching the language to English and accessing a Swedish URL, /test, it redirects to /en/test.As per the documentation, the locale detection process works like this:
Since my setup lacks a locale prefix in the URL pathname due to
localePrefix
being set toas-needed
, next-intl will move on to the next step and detect the locale from the cookie.Is there a way to make next-intl recognize URLs without a locale prefix as Swedish and change the locale accordingly?
Beta Was this translation helpful? Give feedback.
All reactions