mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +00:00
LibUnicode: Generate Unicode locale likely subtag data
CLDR contains a set of likely subtag data where, given a locale, you can resolve what is the most likely language, script, or territory of that locale. This data is needed for resolving territory aliases. These aliases might contain multiple territories, and we need to resolve which of those territories is most likely correct for a locale. Note that the likely subtag data is quite huge (a few thousand entries). As an optimization encouraged by the spec, we only generate the smallest subset of this data that we actually need (about 150 entries).
This commit is contained in:
committed by
Linus Groh
parent
72f49e42b4
commit
1fbc5dba08
@@ -860,4 +860,19 @@ Optional<StringView> resolve_subdivision_alias(StringView subdivision)
|
||||
#endif
|
||||
}
|
||||
|
||||
String resolve_most_likely_territory([[maybe_unused]] LanguageID const& language_id, StringView territory_alias)
|
||||
{
|
||||
auto aliases = territory_alias.split_view(' ');
|
||||
|
||||
#if ENABLE_UNICODE_DATA
|
||||
if (aliases.size() > 1) {
|
||||
auto territory = Detail::resolve_most_likely_territory(language_id);
|
||||
if (territory.has_value() && aliases.contains_slow(*territory))
|
||||
return territory.release_value();
|
||||
}
|
||||
#endif
|
||||
|
||||
return aliases[0].to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user