next-international
next-international copied to clipboard
How to customize the locale prefix to something else while keep using browser language auto-detection?
TLDR
- In short, what we want is
localhost:3000/
for default locale, butlocalhost:3000/us
for english locale, notlocalhost:3000/en
from accept-languages. But, want to keep using browser language detection.
Is your feature request related to a problem? Please describe.
I want to use customized prefix (not the one from the accept-language) of the locale path but didn't find the exact solution. Because we detect the first language from browser header (accept-language), we can't set like locales: ['us', 'de']
since browser just tell us en
value otherwise it redirects to the defaultLocale.
Describe the solution you'd like
If we set en
and de
for the locals but want to rewrite the en
to us
(from en-US
), is it possible to achieve this behavior within this package?
Describe alternatives you've considered
Maybe we can utilize NextRequest and NextResponse before calling I18nMiddleware
in middleware.ts
, but would love to know the solution if you see some right path to achieve this.