mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:55:10 +00:00
LibJS+LibUnicode: Parse Unicode keywords from the BCP 47 CLDR package
We have a fair amount of hard-coded keywords / aliases that can now be replaced with real data from BCP 47. As a result, the also changes the awkward way we were previously generating keys. Before, we were more or less generating keywords as a CSV list of keys, e.g. for the "nu" key, we'd generate "latn,arab,grek" (ordered by locale preference). Then at runtime, we'd split on the comma. We now just generate spans of keywords directly.
This commit is contained in:
parent
d0fc61e79b
commit
89ead8c00a
6 changed files with 236 additions and 121 deletions
|
@ -26,11 +26,8 @@ Vector<NumberFormat> __attribute__((weak)) get_unit_formats(StringView, StringVi
|
|||
|
||||
Optional<StringView> get_default_number_system(StringView locale)
|
||||
{
|
||||
if (auto systems = get_locale_key_mapping(locale, "nu"sv); systems.has_value()) {
|
||||
auto index = systems->find(',');
|
||||
return index.has_value() ? systems->substring_view(0, *index) : *systems;
|
||||
}
|
||||
|
||||
if (auto systems = get_keywords_for_locale(locale, "nu"sv); !systems.is_empty())
|
||||
return systems[0];
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue