summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibUnicode/Locale.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-02-15 12:23:26 -0500
committerTim Flynn <trflynn89@pm.me>2022-02-16 07:23:07 -0500
commit89ead8c00a7c25aca8ab0022f09babcea9485bc2 (patch)
tree855a3784dea7be6e58223975ccee01b8cbd859ba /Userland/Libraries/LibUnicode/Locale.cpp
parentd0fc61e79bc3580c9557c22de3299623a9099c6c (diff)
downloadserenity-89ead8c00a7c25aca8ab0022f09babcea9485bc2.zip
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.
Diffstat (limited to 'Userland/Libraries/LibUnicode/Locale.cpp')
-rw-r--r--Userland/Libraries/LibUnicode/Locale.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/Userland/Libraries/LibUnicode/Locale.cpp b/Userland/Libraries/LibUnicode/Locale.cpp
index fa191ca651..71b7c11912 100644
--- a/Userland/Libraries/LibUnicode/Locale.cpp
+++ b/Userland/Libraries/LibUnicode/Locale.cpp
@@ -771,10 +771,14 @@ Optional<Language> __attribute__((weak)) language_from_string(StringView) { retu
Optional<Territory> __attribute__((weak)) territory_from_string(StringView) { return {}; }
Optional<ScriptTag> __attribute__((weak)) script_tag_from_string(StringView) { return {}; }
Optional<Currency> __attribute__((weak)) currency_from_string(StringView) { return {}; }
-Optional<CalendarName> __attribute__((weak)) calendar_name_from_string(StringView) { return {}; }
Optional<DateField> __attribute__((weak)) date_field_from_string(StringView) { return {}; }
-Optional<Key> __attribute__((weak)) key_from_string(StringView) { return {}; }
Optional<ListPatternType> __attribute__((weak)) list_pattern_type_from_string(StringView) { return {}; }
+Optional<Key> __attribute__((weak)) key_from_string(StringView) { return {}; }
+Optional<KeywordCalendar> __attribute__((weak)) keyword_ca_from_string(StringView) { return {}; }
+Optional<KeywordColCaseFirst> __attribute__((weak)) keyword_kf_from_string(StringView) { return {}; }
+Optional<KeywordColNumeric> __attribute__((weak)) keyword_kn_from_string(StringView) { return {}; }
+Optional<KeywordNumbers> __attribute__((weak)) keyword_nu_from_string(StringView) { return {}; }
+Vector<StringView> __attribute__((weak)) get_keywords_for_locale(StringView, StringView) { return {}; }
Optional<DisplayPattern> __attribute__((weak)) get_locale_display_patterns(StringView) { return {}; }
Optional<StringView> __attribute__((weak)) get_locale_language_mapping(StringView, StringView) { return {}; }
Optional<StringView> __attribute__((weak)) get_locale_territory_mapping(StringView, StringView) { return {}; }
@@ -787,7 +791,6 @@ Optional<StringView> __attribute__((weak)) get_locale_calendar_mapping(StringVie
Optional<StringView> __attribute__((weak)) get_locale_long_date_field_mapping(StringView, StringView) { return {}; }
Optional<StringView> __attribute__((weak)) get_locale_short_date_field_mapping(StringView, StringView) { return {}; }
Optional<StringView> __attribute__((weak)) get_locale_narrow_date_field_mapping(StringView, StringView) { return {}; }
-Optional<StringView> __attribute__((weak)) get_locale_key_mapping(StringView, StringView) { return {}; }
// https://www.unicode.org/reports/tr35/tr35-39/tr35-general.html#Display_Name_Elements
Optional<String> format_locale_for_display(StringView locale, LocaleID locale_id)
@@ -823,26 +826,6 @@ Optional<String> format_locale_for_display(StringView locale, LocaleID locale_id
return patterns->locale_pattern.replace("{0}"sv, primary_tag).replace("{1}"sv, *secondary_tag);
}
-Vector<StringView> get_locale_key_mapping_list(StringView locale, StringView keyword)
-{
- if (keyword == "hc"sv) {
- auto hour_cycles = get_locale_hour_cycles(locale);
-
- Vector<StringView> values;
- values.ensure_capacity(hour_cycles.size());
-
- for (auto hour_cycle : hour_cycles)
- values.unchecked_append(hour_cycle_to_string(hour_cycle));
-
- return values;
- }
-
- if (auto values = get_locale_key_mapping(locale, keyword); values.has_value())
- return values->split_view(',');
-
- return {};
-}
-
Optional<ListPatterns> __attribute__((weak)) get_locale_list_patterns(StringView, StringView, Style) { return {}; }
Optional<StringView> __attribute__((weak)) resolve_language_alias(StringView) { return {}; }
Optional<StringView> __attribute__((weak)) resolve_territory_alias(StringView) { return {}; }