pub fn best_match(
preferred: &[LangCode],
offered: &[LangCode],
) -> Option<LangCode>Expand description
The offered language that fits the system’s: preferred is the
system’s languages, most preferred first, and offered the source’s tag
and the packs’. For each preferred tag in order:
- the tag, then each of its
parents, if offered (en-GBmatches anensource); - Chinese without a script takes one from its region (
CNandSGgiveHans;TW,HKandMOgiveHant), then step 1 again with the script written after the language (zh-CNmatcheszh-Hans, throughzh-Hans-CN); - the only offered tag with the same language subtag, unless both have
a script (written, or from step 2) and they differ (
pt-PTmatches a lonept-BR;zh-TWdoesn’t matchzh-Hans).
The first preferred tag that matches wins. None if none does: the
caller then uses the source. No CLDR data: no likely subtags beyond
step 2’s five regions, no aliases, and no parent but the shorter tag.