diff options
-rw-r--r-- | Tests/LibUnicode/TestUnicodeLocale.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibUnicode/Locale.cpp | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/Tests/LibUnicode/TestUnicodeLocale.cpp b/Tests/LibUnicode/TestUnicodeLocale.cpp index 85bf18dac2..878c6c2731 100644 --- a/Tests/LibUnicode/TestUnicodeLocale.cpp +++ b/Tests/LibUnicode/TestUnicodeLocale.cpp @@ -316,6 +316,10 @@ TEST_CASE(canonicalize_unicode_locale_id) test("EN-U-MS-IMPERIAL"sv, "en-u-ms-uksystem"sv); test("en-u-ma-imperial"sv, "en-u-ma-imperial"sv); test("EN-U-MA-IMPERIAL"sv, "en-u-ma-imperial"sv); + test("en-u-tz-hongkong"sv, "en-u-tz-hkhkg"sv); + test("EN-U-TZ-HONGKONG"sv, "en-u-tz-hkhkg"sv); + test("en-u-ta-hongkong"sv, "en-u-ta-hongkong"sv); + test("EN-U-TA-HONGKONG"sv, "en-u-ta-hongkong"sv); test("en-t-en"sv, "en-t-en"sv); test("EN-T-EN"sv, "en-t-en"sv); @@ -339,6 +343,8 @@ TEST_CASE(canonicalize_unicode_locale_id) test("EN-T-K1-PRIMARY"sv, "en-t-k1-primary"sv); test("en-t-k1-imperial"sv, "en-t-k1-imperial"sv); test("EN-T-K1-IMPERIAL"sv, "en-t-k1-imperial"sv); + test("en-t-k1-hongkong"sv, "en-t-k1-hongkong"sv); + test("EN-T-K1-HONGKONG"sv, "en-t-k1-hongkong"sv); test("en-0-aaa"sv, "en-0-aaa"sv); test("EN-0-AAA"sv, "en-0-aaa"sv); diff --git a/Userland/Libraries/LibUnicode/Locale.cpp b/Userland/Libraries/LibUnicode/Locale.cpp index 5815f3678e..e91561c5ea 100644 --- a/Userland/Libraries/LibUnicode/Locale.cpp +++ b/Userland/Libraries/LibUnicode/Locale.cpp @@ -485,6 +485,7 @@ static void perform_hard_coded_key_value_substitutions(String& key, String& valu // FIXME: In the XML export of CLDR, there are some aliases defined in the following files: // https://github.com/unicode-org/cldr-staging/blob/master/production/common/bcp47/collation.xml // https://github.com/unicode-org/cldr-staging/blob/master/production/common/bcp47/measure.xml + // https://github.com/unicode-org/cldr-staging/blob/master/production/common/bcp47/timezone.xml // https://github.com/unicode-org/cldr-staging/blob/master/production/common/bcp47/transform.xml // // There doesn't seem to be a counterpart in the JSON export. Since there aren't many such @@ -502,6 +503,40 @@ static void perform_hard_coded_key_value_substitutions(String& key, String& valu value = "prprname"sv; } else if ((key == "ms"sv) && (value == "imperial"sv)) { value = "uksystem"sv; + } else if (key == "tz"sv) { + // Formatter disabled because this block is easier to read / check against timezone.xml as one-liners. + // clang-format off + if (value == "aqams"sv) value = "nzakl"sv; + else if (value == "cnckg"sv) value = "cnsha"sv; + else if (value == "cnhrb"sv) value = "cnsha"sv; + else if (value == "cnkhg"sv) value = "cnurc"sv; + else if (value == "cuba"sv) value = "cuhav"sv; + else if (value == "egypt"sv) value = "egcai"sv; + else if (value == "eire"sv) value = "iedub"sv; + else if (value == "est"sv) value = "utcw05"sv; + else if (value == "gmt0"sv) value = "gmt"sv; + else if (value == "hongkong"sv) value = "hkhkg"sv; + else if (value == "hst"sv) value = "utcw10"sv; + else if (value == "iceland"sv) value = "isrey"sv; + else if (value == "iran"sv) value = "irthr"sv; + else if (value == "israel"sv) value = "jeruslm"sv; + else if (value == "jamaica"sv) value = "jmkin"sv; + else if (value == "japan"sv) value = "jptyo"sv; + else if (value == "kwajalein"sv) value = "mhkwa"sv; + else if (value == "libya"sv) value = "lytip"sv; + else if (value == "mst"sv) value = "utcw07"sv; + else if (value == "navajo"sv) value = "usden"sv; + else if (value == "poland"sv) value = "plwaw"sv; + else if (value == "portugal"sv) value = "ptlis"sv; + else if (value == "prc"sv) value = "cnsha"sv; + else if (value == "roc"sv) value = "twtpe"sv; + else if (value == "rok"sv) value = "krsel"sv; + else if (value == "singapore"sv) value = "sgsin"sv; + else if (value == "turkey"sv) value = "trist"sv; + else if (value == "uct"sv) value = "utc"sv; + else if (value == "usnavajo"sv) value = "usden"sv; + else if (value == "zulu"sv) value = "utc"sv; + // clang-format on } } |