-
I'm using next-int with a Next.js 14 App router using 18n routing. I assumed that if the browser locale was set to
I only have the generic locales in my app (not country-specific). If I set my browser to "Spanish", then the auto detection works fine and the Is there a way to have this behaviour automatically without having to explicitely list every country-specific locale? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Based on your outcome, I'd assume that
Example: import {match} from '@formatjs/intl-localematcher';
const requestedLocales = ['es-AR', 'en'];
const availableLocales = ['es', 'en'];
const defaultLocale = 'en';
// 'en', since 'en' is a supported language (even if ordered after 'es')
match(requestedLocales, availableLocales, defaultLocale) However: const requestedLocales = ['es-AR', 'de']; // Note that `en` is no longer requested
const availableLocales = ['es', 'en'];
const defaultLocale = 'en';
// 'es'
match(requestedLocales, availableLocales, defaultLocale) I see your point though about why However, checking e.g. my browser which has a preference for American English, but also German, the
So the browser also decided to add |
Beta Was this translation helpful? Give feedback.
next-intl
reads theaccept-language
header and uses that to negotiate a matching locale. Did you check the value of the header in your case?Based on your outcome, I'd assume that
en
is also in your list (even if secondary).next-intl
uses@formatjs/intl-localematcher
under the hood for this matching.Example:
However: