1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibUnicode: Support locales-without-script aliases for ECMA-402

As noted by ECMA-402, if a supported locale contains all of a language,
script, and region subtag, then the implementation must also support the
locale without the script subtag. The most complicated example of this
is the zh-TW locale.

The list of locales in the CLDR database does not include zh-TW or its
maximized zh-Hant-TW variant. Instead, it inlcudes the zh-Hant locale.
However, zh-Hant-TW is listed in the default-content locale list in the
cldr-core package. This defines an alias from zh-Hant-TW to zh-Hant. We
must then also support the zh-Hant-TW alias without the script subtag:
zh-TW. This transitively maps zh-TW to zh-Hant, which is a case quite
heavily tested by test262.
This commit is contained in:
Timothy Flynn 2021-11-17 09:56:16 -05:00 committed by Andreas Kling
parent 4b535ce1c8
commit 93ee922027
2 changed files with 51 additions and 0 deletions

View file

@ -463,3 +463,11 @@ TEST_CASE(canonicalize_unicode_locale_id)
test("zh-Hans-CN"sv, "zh-Hans-CN"sv);
test("ZH-HANS-CN"sv, "zh-Hans-CN"sv);
}
TEST_CASE(supports_locale_aliases)
{
EXPECT(Unicode::is_locale_available("zh"sv));
EXPECT(Unicode::is_locale_available("zh-Hant"sv));
EXPECT(Unicode::is_locale_available("zh-TW"sv));
EXPECT(Unicode::is_locale_available("zh-Hant-TW"sv));
}