Match a BCP 47 language preference to available languages
bcp_match_language.RdImplements the "Lookup" scheme from RFC 4647 Section 3.4: given an ordered
list of language tag preferences and a set of available tags, returns the
best match. Matching proceeds by progressively stripping the rightmost
subtag from each preference until a match is found or no subtags remain.
Single-character subtags (including the private-use prefix "x") are always
stripped as a unit together with any preceding single-character subtags.
Arguments
- preferences
A character vector of BCP 47 language tags representing the caller's ordered preferences, from most to least preferred.
- available
A character vector of BCP 47 language tags that are available to choose from.
- default
The value to return when no preference matches any available tag. Defaults to
NULL.