Skip to main content

Function: negotiateLocale()

negotiateLocale(__namedParameters): string

Defined in: negotiateLocale.ts:55

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.

Parameters​

ParameterType
__namedParameters{ fallback: string; requested?: string | string[] | null; supported: string[]; }
__namedParameters.fallbackstring
__namedParameters.requested?string | string[] | null
__namedParameters.supportedstring[]

Returns​

string