Преглед изворни кода

LibUnicode: Fill in case-first and numeric BCP47 keywords

Unlike other BCP47 keywords that we are parsing, these only appear in
the BCP47 XML file itself within the CLDR. The values are very simple
though, so just hard code them until the Unicode org re-releases the
CLDR with BCP47: https://unicode-org.atlassian.net/browse/CLDR-15158
Timothy Flynn пре 3 година
родитељ
комит
4d43aeae30
1 измењених фајлова са 13 додато и 1 уклоњено
  1. 13 1
      Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp

+ 13 - 1
Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp

@@ -215,7 +215,7 @@ struct UnicodeLocaleData {
         { "week"sv, "weekOfYear"sv },
         { "zone"sv, "timeZoneName"sv },
     };
-    Vector<String> keywords { "ca"sv, "nu"sv }; // FIXME: These should be parsed from BCP47. https://unicode-org.atlassian.net/browse/CLDR-15158
+    Vector<String> keywords { "ca"sv, "kf"sv, "kn"sv, "nu"sv }; // FIXME: These should be parsed from BCP47. https://unicode-org.atlassian.net/browse/CLDR-15158
     Vector<String> list_pattern_types;
     HashMap<String, StringIndexType> language_aliases;
     HashMap<String, StringIndexType> territory_aliases;
@@ -743,6 +743,17 @@ static ErrorOr<void> parse_calendar_keywords(String locale_dates_path, UnicodeLo
     return {};
 }
 
+static void fill_in_bcp47_keywords(UnicodeLocaleData& locale_data, KeywordList& keywords)
+{
+    // FIXME: These should be parsed from BCP47. They are only available in this XML file:
+    //        https://github.com/unicode-org/cldr/blob/main/common/bcp47/collation.xml
+    auto kf_index = locale_data.keywords.find_first_index("kf"sv).value();
+    keywords[kf_index] = locale_data.unique_strings.ensure("upper,lower,false"sv);
+
+    auto kn_index = locale_data.keywords.find_first_index("kn"sv).value();
+    keywords[kn_index] = locale_data.unique_strings.ensure("true,false"sv);
+}
+
 static ErrorOr<void> parse_default_content_locales(String core_path, UnicodeLocaleData& locale_data)
 {
     LexicalPath default_content_path(move(core_path));
@@ -902,6 +913,7 @@ static ErrorOr<void> parse_all_locales(String core_path, String locale_names_pat
 
         auto& keywords = ensure_keyword_list(language);
         TRY(parse_numeric_keywords(numbers_path, locale_data, keywords));
+        fill_in_bcp47_keywords(locale_data, keywords);
     }
 
     while (dates_iterator.has_next()) {