Skip to content

languageTagPrefixes

languageTagPrefixes(tag): string[]

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

A language tag and each of its progressive truncations, longest first.

en-Latn-US-u-co-phonebk yields en-Latn-US-u-co, then en-Latn-US — skipping en-Latn-US-u, since RFC 4647 §3.4 discards a truncation that ends in a singleton subtag — then en-Latn and en.

Accepts any hyphen-separated subtag sequence, not only a well-formed tag, because lookupLanguageTag truncates ranges with it.

Runs in O(n²) characters for n subtags, which is bounded by the grammar.

string

string[]