Skip to content

lookupLanguageTag

lookupLanguageTag(available, ranges, options?): string | null

Defined in: packages/format-language-tag/src/match-language.ts:126

The single best available tag for a priority list of ranges, per RFC 4647 §3.4 Lookup.

Each range is truncated a subtag at a time until one of the truncations is an available tag; the first range to produce one wins. A * subtag carries no information a truncation could use, so it is dropped, and a range of nothing but * is skipped rather than treated as matching everything — a caller that wants a fallback says so with defaultTag.

Where two available tags differ only in case, the first one wins.

Iterable<string>

Iterable<string>

LanguageLookupOptions

string | null