Function: negotiateLocale()
Call Signature
negotiateLocale(
args):string
Defined in: negotiateLocale.ts:56
Pick the supported locale that best serves what was requested — a user
preference, an Accept-Language header, or both in priority order.
For each requested locale, in order: an exact match, then the locale with
its subtags dropped one at a time (pt-BR → pt), then any supported
locale of the same language (pt-PT → pt-BR). Only when no requested
locale matches at all does fallback apply; without one, the result is
undefined, so a caller can tell "nothing matched" from a real match.
Parameters
| Parameter | Type |
|---|---|
args | { fallback: string; requested?: string | string[] | null; supported: string[]; } |
args.fallback | string |
args.requested? | string | string[] | null |
args.supported | string[] |
Returns
string
Call Signature
negotiateLocale(
args):string|undefined
Defined in: negotiateLocale.ts:61
Pick the supported locale that best serves what was requested — a user
preference, an Accept-Language header, or both in priority order.
For each requested locale, in order: an exact match, then the locale with
its subtags dropped one at a time (pt-BR → pt), then any supported
locale of the same language (pt-PT → pt-BR). Only when no requested
locale matches at all does fallback apply; without one, the result is
undefined, so a caller can tell "nothing matched" from a real match.
Parameters
| Parameter | Type |
|---|---|
args | { fallback?: undefined; requested?: string | string[] | null; supported: string[]; } |
args.fallback? | undefined |
args.requested? | string | string[] | null |
args.supported | string[] |
Returns
string | undefined