diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 55f034e7d59..abbd307337b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,7 +10,6 @@ /Userland/Libraries/LibCrypto @alimpfard /Userland/Libraries/LibHTTP @alimpfard /Userland/Libraries/LibJS/Runtime/Intl @trflynn89 -/Userland/Libraries/LibLocale @trflynn89 /Userland/Libraries/LibRegex @alimpfard /Userland/Libraries/LibTLS @alimpfard /Userland/Libraries/LibTimeZone @trflynn89 diff --git a/Ladybird/WebWorker/CMakeLists.txt b/Ladybird/WebWorker/CMakeLists.txt index 84652684bef..38af4f2347a 100644 --- a/Ladybird/WebWorker/CMakeLists.txt +++ b/Ladybird/WebWorker/CMakeLists.txt @@ -22,7 +22,7 @@ add_library(webworker STATIC ${WEBWORKER_SOURCES}) target_include_directories(webworker PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/Services/) target_include_directories(webworker PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/) target_include_directories(webworker PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -target_link_libraries(webworker PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibProtocol LibWeb LibWebView LibLocale LibImageDecoderClient LibMain LibURL) +target_link_libraries(webworker PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibProtocol LibWeb LibWebView LibUnicode LibImageDecoderClient LibMain LibURL) if (HAS_FONTCONFIG) target_link_libraries(webworker PRIVATE Fontconfig::Fontconfig) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index d866e51aa66..2fdc738dcea 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -394,7 +394,6 @@ set(lagom_standard_libraries IPC JS Line - Locale Media Protocol Regex @@ -437,9 +436,6 @@ foreach(lib IN LISTS lagom_standard_libraries) add_serenity_subdirectory("Userland/Libraries/Lib${lib}") endforeach() -# FIXME: Why is this not in LibLocale/CMakeLists.txt? -target_link_libraries(LibLocale PRIVATE LibTimeZone) - if (ENABLE_FUZZERS) add_subdirectory(Fuzzers) endif() @@ -460,7 +456,7 @@ lagom_utility(gzip SOURCES ../../Userland/Utilities/gzip.cpp LIBS LibCompress Li lagom_utility(icc SOURCES ../../Userland/Utilities/icc.cpp LIBS LibGfx LibMain LibURL) lagom_utility(image SOURCES ../../Userland/Utilities/image.cpp LIBS LibGfx LibMain) lagom_utility(ttfdisasm SOURCES ../../Userland/Utilities/ttfdisasm.cpp LIBS LibGfx LibMain) -lagom_utility(js SOURCES ../../Userland/Utilities/js.cpp LIBS LibCrypto LibJS LibLine LibLocale LibMain LibTextCodec Threads::Threads) +lagom_utility(js SOURCES ../../Userland/Utilities/js.cpp LIBS LibCrypto LibJS LibLine LibUnicode LibMain LibTextCodec Threads::Threads) lagom_utility(lzcat SOURCES ../../Userland/Utilities/lzcat.cpp LIBS LibCompress LibMain) @@ -513,7 +509,6 @@ if (BUILD_TESTING) LibCrypto LibCompress LibGfx - LibLocale LibMedia LibTest LibTextCodec diff --git a/README.md b/README.md index 4ad9e9b9f45..d6577596e36 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ At the moment, many core library support components are inherited from SerenityO - LibHTTP: HTTP/1.1 client - LibGfx: 2D Graphics Library, Image Decoding and Rendering - LibArchive: Archive file format support -- LibUnicode, LibLocale: Unicode and locale support +- LibUnicode: Unicode and locale support - LibAudio, LibMedia: Audio and video playback - LibCore: Event loop, OS abstraction layer - LibIPC: Inter-process communication diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0c43e429ea3..eec6e3ce996 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -5,7 +5,6 @@ add_subdirectory(LibCore) add_subdirectory(LibDiff) add_subdirectory(LibGfx) add_subdirectory(LibJS) -add_subdirectory(LibLocale) add_subdirectory(LibRegex) add_subdirectory(LibTest) add_subdirectory(LibTextCodec) diff --git a/Tests/LibJS/CMakeLists.txt b/Tests/LibJS/CMakeLists.txt index 71075fc3dca..be77c612047 100644 --- a/Tests/LibJS/CMakeLists.txt +++ b/Tests/LibJS/CMakeLists.txt @@ -1,13 +1,13 @@ -serenity_testjs_test(test-js.cpp test-js LIBS LibLocale) +serenity_testjs_test(test-js.cpp test-js LIBS LibUnicode) install(TARGETS test-js RUNTIME DESTINATION bin OPTIONAL) -serenity_test(test-invalid-unicode-js.cpp LibJS LIBS LibJS LibLocale) +serenity_test(test-invalid-unicode-js.cpp LibJS LIBS LibJS LibUnicode) -serenity_test(test-value-js.cpp LibJS LIBS LibJS LibLocale) +serenity_test(test-value-js.cpp LibJS LIBS LibJS LibUnicode) add_executable(test262-runner test262-runner.cpp) -target_link_libraries(test262-runner PRIVATE LibJS LibCore LibLocale) +target_link_libraries(test262-runner PRIVATE LibJS LibCore LibUnicode) serenity_set_implicit_links(test262-runner) install(TARGETS test262-runner RUNTIME DESTINATION bin OPTIONAL) diff --git a/Tests/LibLocale/CMakeLists.txt b/Tests/LibLocale/CMakeLists.txt deleted file mode 100644 index d59c695afed..00000000000 --- a/Tests/LibLocale/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(TEST_SOURCES - TestDisplayNames.cpp - TestLocale.cpp - TestSegmenter.cpp -) - -foreach(source IN LISTS TEST_SOURCES) - serenity_test("${source}" LibLocale LIBS LibLocale) -endforeach() diff --git a/Tests/LibLocale/TestDisplayNames.cpp b/Tests/LibLocale/TestDisplayNames.cpp deleted file mode 100644 index 44df60557df..00000000000 --- a/Tests/LibLocale/TestDisplayNames.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2021, Tim Flynn - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -#include -#include - -TEST_CASE(locale_mappings_en) -{ - auto language = Locale::language_display_name("en"sv, "en"sv, Locale::LanguageDisplay::Standard); - EXPECT(language.has_value()); - EXPECT_EQ(*language, "English"sv); - - language = Locale::language_display_name("en"sv, "i-defintely-don't-exist"sv, Locale::LanguageDisplay::Standard); - EXPECT(!language.has_value()); - - auto territory = Locale::region_display_name("en"sv, "US"sv); - EXPECT(territory.has_value()); - EXPECT_EQ(*territory, "United States"sv); - - territory = Locale::region_display_name("en"sv, "i-defintely-don't-exist"sv); - EXPECT(!territory.has_value()); - - auto script = Locale::script_display_name("en"sv, "Latn"sv); - EXPECT(script.has_value()); - EXPECT_EQ(*script, "Latin"sv); - - script = Locale::script_display_name("en"sv, "i-defintely-don't-exist"sv); - EXPECT(!script.has_value()); -} - -TEST_CASE(locale_mappings_fr) -{ - auto language = Locale::language_display_name("fr"sv, "en"sv, Locale::LanguageDisplay::Standard); - EXPECT(language.has_value()); - EXPECT_EQ(*language, "anglais"sv); - - language = Locale::language_display_name("fr"sv, "i-defintely-don't-exist"sv, Locale::LanguageDisplay::Standard); - EXPECT(!language.has_value()); - - auto territory = Locale::region_display_name("fr"sv, "US"sv); - EXPECT(territory.has_value()); - EXPECT_EQ(*territory, "États-Unis"sv); - - territory = Locale::region_display_name("fr"sv, "i-defintely-don't-exist"sv); - EXPECT(!territory.has_value()); - - auto script = Locale::script_display_name("fr"sv, "Latn"sv); - EXPECT(script.has_value()); - EXPECT_EQ(*script, "latin"sv); - - script = Locale::script_display_name("fr"sv, "i-defintely-don't-exist"sv); - EXPECT(!script.has_value()); -} - -TEST_CASE(locale_mappings_root) -{ - auto language = Locale::language_display_name("und"sv, "en"sv, Locale::LanguageDisplay::Standard); - EXPECT(language.has_value()); - EXPECT_EQ(*language, "en"sv); - - language = Locale::language_display_name("und"sv, "i-defintely-don't-exist"sv, Locale::LanguageDisplay::Standard); - EXPECT(!language.has_value()); - - auto territory = Locale::region_display_name("und"sv, "US"sv); - EXPECT(territory.has_value()); - EXPECT_EQ(*territory, "US"sv); - - territory = Locale::region_display_name("und"sv, "i-defintely-don't-exist"sv); - EXPECT(!territory.has_value()); - - auto script = Locale::script_display_name("und"sv, "Latn"sv); - EXPECT(script.has_value()); - EXPECT_EQ(*script, "Latn"sv); - - script = Locale::script_display_name("und"sv, "i-defintely-don't-exist"sv); - EXPECT(!script.has_value()); -} diff --git a/Tests/LibUnicode/CMakeLists.txt b/Tests/LibUnicode/CMakeLists.txt index df330dcb480..c074a75d820 100644 --- a/Tests/LibUnicode/CMakeLists.txt +++ b/Tests/LibUnicode/CMakeLists.txt @@ -1,6 +1,9 @@ set(TEST_SOURCES + TestDisplayNames.cpp TestEmoji.cpp TestIDNA.cpp + TestLocale.cpp + TestSegmenter.cpp TestUnicodeCharacterTypes.cpp TestUnicodeNormalization.cpp ) diff --git a/Tests/LibUnicode/TestDisplayNames.cpp b/Tests/LibUnicode/TestDisplayNames.cpp new file mode 100644 index 00000000000..f192649c59a --- /dev/null +++ b/Tests/LibUnicode/TestDisplayNames.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021, Tim Flynn + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +#include +#include + +TEST_CASE(locale_mappings_en) +{ + auto language = Unicode::language_display_name("en"sv, "en"sv, Unicode::LanguageDisplay::Standard); + EXPECT(language.has_value()); + EXPECT_EQ(*language, "English"sv); + + language = Unicode::language_display_name("en"sv, "i-defintely-don't-exist"sv, Unicode::LanguageDisplay::Standard); + EXPECT(!language.has_value()); + + auto territory = Unicode::region_display_name("en"sv, "US"sv); + EXPECT(territory.has_value()); + EXPECT_EQ(*territory, "United States"sv); + + territory = Unicode::region_display_name("en"sv, "i-defintely-don't-exist"sv); + EXPECT(!territory.has_value()); + + auto script = Unicode::script_display_name("en"sv, "Latn"sv); + EXPECT(script.has_value()); + EXPECT_EQ(*script, "Latin"sv); + + script = Unicode::script_display_name("en"sv, "i-defintely-don't-exist"sv); + EXPECT(!script.has_value()); +} + +TEST_CASE(locale_mappings_fr) +{ + auto language = Unicode::language_display_name("fr"sv, "en"sv, Unicode::LanguageDisplay::Standard); + EXPECT(language.has_value()); + EXPECT_EQ(*language, "anglais"sv); + + language = Unicode::language_display_name("fr"sv, "i-defintely-don't-exist"sv, Unicode::LanguageDisplay::Standard); + EXPECT(!language.has_value()); + + auto territory = Unicode::region_display_name("fr"sv, "US"sv); + EXPECT(territory.has_value()); + EXPECT_EQ(*territory, "États-Unis"sv); + + territory = Unicode::region_display_name("fr"sv, "i-defintely-don't-exist"sv); + EXPECT(!territory.has_value()); + + auto script = Unicode::script_display_name("fr"sv, "Latn"sv); + EXPECT(script.has_value()); + EXPECT_EQ(*script, "latin"sv); + + script = Unicode::script_display_name("fr"sv, "i-defintely-don't-exist"sv); + EXPECT(!script.has_value()); +} + +TEST_CASE(locale_mappings_root) +{ + auto language = Unicode::language_display_name("und"sv, "en"sv, Unicode::LanguageDisplay::Standard); + EXPECT(language.has_value()); + EXPECT_EQ(*language, "en"sv); + + language = Unicode::language_display_name("und"sv, "i-defintely-don't-exist"sv, Unicode::LanguageDisplay::Standard); + EXPECT(!language.has_value()); + + auto territory = Unicode::region_display_name("und"sv, "US"sv); + EXPECT(territory.has_value()); + EXPECT_EQ(*territory, "US"sv); + + territory = Unicode::region_display_name("und"sv, "i-defintely-don't-exist"sv); + EXPECT(!territory.has_value()); + + auto script = Unicode::script_display_name("und"sv, "Latn"sv); + EXPECT(script.has_value()); + EXPECT_EQ(*script, "Latn"sv); + + script = Unicode::script_display_name("und"sv, "i-defintely-don't-exist"sv); + EXPECT(!script.has_value()); +} diff --git a/Tests/LibLocale/TestLocale.cpp b/Tests/LibUnicode/TestLocale.cpp similarity index 80% rename from Tests/LibLocale/TestLocale.cpp rename to Tests/LibUnicode/TestLocale.cpp index 022c47b2198..644d3757bcf 100644 --- a/Tests/LibLocale/TestLocale.cpp +++ b/Tests/LibUnicode/TestLocale.cpp @@ -6,85 +6,85 @@ #include -#include +#include TEST_CASE(is_unicode_language_subtag) { - EXPECT(Locale::is_unicode_language_subtag("aa"sv)); - EXPECT(Locale::is_unicode_language_subtag("aaa"sv)); - EXPECT(Locale::is_unicode_language_subtag("aaaaa"sv)); - EXPECT(Locale::is_unicode_language_subtag("aaaaaa"sv)); - EXPECT(Locale::is_unicode_language_subtag("aaaaaaa"sv)); - EXPECT(Locale::is_unicode_language_subtag("aaaaaaaa"sv)); + EXPECT(Unicode::is_unicode_language_subtag("aa"sv)); + EXPECT(Unicode::is_unicode_language_subtag("aaa"sv)); + EXPECT(Unicode::is_unicode_language_subtag("aaaaa"sv)); + EXPECT(Unicode::is_unicode_language_subtag("aaaaaa"sv)); + EXPECT(Unicode::is_unicode_language_subtag("aaaaaaa"sv)); + EXPECT(Unicode::is_unicode_language_subtag("aaaaaaaa"sv)); - EXPECT(!Locale::is_unicode_language_subtag(""sv)); - EXPECT(!Locale::is_unicode_language_subtag("a"sv)); - EXPECT(!Locale::is_unicode_language_subtag("aaaa"sv)); - EXPECT(!Locale::is_unicode_language_subtag("aaaaaaaaa"sv)); - EXPECT(!Locale::is_unicode_language_subtag("123"sv)); + EXPECT(!Unicode::is_unicode_language_subtag(""sv)); + EXPECT(!Unicode::is_unicode_language_subtag("a"sv)); + EXPECT(!Unicode::is_unicode_language_subtag("aaaa"sv)); + EXPECT(!Unicode::is_unicode_language_subtag("aaaaaaaaa"sv)); + EXPECT(!Unicode::is_unicode_language_subtag("123"sv)); } TEST_CASE(is_unicode_script_subtag) { - EXPECT(Locale::is_unicode_script_subtag("aaaa"sv)); + EXPECT(Unicode::is_unicode_script_subtag("aaaa"sv)); - EXPECT(!Locale::is_unicode_script_subtag(""sv)); - EXPECT(!Locale::is_unicode_script_subtag("a"sv)); - EXPECT(!Locale::is_unicode_script_subtag("aa"sv)); - EXPECT(!Locale::is_unicode_script_subtag("aaa"sv)); - EXPECT(!Locale::is_unicode_script_subtag("aaaaa"sv)); - EXPECT(!Locale::is_unicode_script_subtag("1234"sv)); + EXPECT(!Unicode::is_unicode_script_subtag(""sv)); + EXPECT(!Unicode::is_unicode_script_subtag("a"sv)); + EXPECT(!Unicode::is_unicode_script_subtag("aa"sv)); + EXPECT(!Unicode::is_unicode_script_subtag("aaa"sv)); + EXPECT(!Unicode::is_unicode_script_subtag("aaaaa"sv)); + EXPECT(!Unicode::is_unicode_script_subtag("1234"sv)); } TEST_CASE(is_unicode_region_subtag) { - EXPECT(Locale::is_unicode_region_subtag("aa"sv)); - EXPECT(Locale::is_unicode_region_subtag("123"sv)); + EXPECT(Unicode::is_unicode_region_subtag("aa"sv)); + EXPECT(Unicode::is_unicode_region_subtag("123"sv)); - EXPECT(!Locale::is_unicode_region_subtag(""sv)); - EXPECT(!Locale::is_unicode_region_subtag("a"sv)); - EXPECT(!Locale::is_unicode_region_subtag("aaa"sv)); - EXPECT(!Locale::is_unicode_region_subtag("12"sv)); - EXPECT(!Locale::is_unicode_region_subtag("12a"sv)); + EXPECT(!Unicode::is_unicode_region_subtag(""sv)); + EXPECT(!Unicode::is_unicode_region_subtag("a"sv)); + EXPECT(!Unicode::is_unicode_region_subtag("aaa"sv)); + EXPECT(!Unicode::is_unicode_region_subtag("12"sv)); + EXPECT(!Unicode::is_unicode_region_subtag("12a"sv)); } TEST_CASE(is_unicode_variant_subtag) { - EXPECT(Locale::is_unicode_variant_subtag("aaaaa"sv)); - EXPECT(Locale::is_unicode_variant_subtag("aaaaaa"sv)); - EXPECT(Locale::is_unicode_variant_subtag("aaaaaaa"sv)); - EXPECT(Locale::is_unicode_variant_subtag("aaaaaaaa"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("aaaaa"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("aaaaaa"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("aaaaaaa"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("aaaaaaaa"sv)); - EXPECT(Locale::is_unicode_variant_subtag("1aaa"sv)); - EXPECT(Locale::is_unicode_variant_subtag("12aa"sv)); - EXPECT(Locale::is_unicode_variant_subtag("123a"sv)); - EXPECT(Locale::is_unicode_variant_subtag("1234"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("1aaa"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("12aa"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("123a"sv)); + EXPECT(Unicode::is_unicode_variant_subtag("1234"sv)); - EXPECT(!Locale::is_unicode_variant_subtag(""sv)); - EXPECT(!Locale::is_unicode_variant_subtag("a"sv)); - EXPECT(!Locale::is_unicode_variant_subtag("aa"sv)); - EXPECT(!Locale::is_unicode_variant_subtag("aaa"sv)); - EXPECT(!Locale::is_unicode_variant_subtag("aaaa"sv)); - EXPECT(!Locale::is_unicode_variant_subtag("aaaaaaaaa"sv)); - EXPECT(!Locale::is_unicode_variant_subtag("a234"sv)); + EXPECT(!Unicode::is_unicode_variant_subtag(""sv)); + EXPECT(!Unicode::is_unicode_variant_subtag("a"sv)); + EXPECT(!Unicode::is_unicode_variant_subtag("aa"sv)); + EXPECT(!Unicode::is_unicode_variant_subtag("aaa"sv)); + EXPECT(!Unicode::is_unicode_variant_subtag("aaaa"sv)); + EXPECT(!Unicode::is_unicode_variant_subtag("aaaaaaaaa"sv)); + EXPECT(!Unicode::is_unicode_variant_subtag("a234"sv)); } TEST_CASE(is_type_identifier) { - EXPECT(Locale::is_type_identifier("aaaa"sv)); - EXPECT(Locale::is_type_identifier("aaaa-bbbb"sv)); - EXPECT(Locale::is_type_identifier("aaaa-bbbb-cccc"sv)); + EXPECT(Unicode::is_type_identifier("aaaa"sv)); + EXPECT(Unicode::is_type_identifier("aaaa-bbbb"sv)); + EXPECT(Unicode::is_type_identifier("aaaa-bbbb-cccc"sv)); - EXPECT(Locale::is_type_identifier("1aaa"sv)); - EXPECT(Locale::is_type_identifier("12aa"sv)); - EXPECT(Locale::is_type_identifier("123a"sv)); - EXPECT(Locale::is_type_identifier("1234"sv)); + EXPECT(Unicode::is_type_identifier("1aaa"sv)); + EXPECT(Unicode::is_type_identifier("12aa"sv)); + EXPECT(Unicode::is_type_identifier("123a"sv)); + EXPECT(Unicode::is_type_identifier("1234"sv)); - EXPECT(!Locale::is_type_identifier(""sv)); - EXPECT(!Locale::is_type_identifier("a"sv)); - EXPECT(!Locale::is_type_identifier("aa"sv)); - EXPECT(!Locale::is_type_identifier("aaaaaaaaa"sv)); - EXPECT(!Locale::is_type_identifier("aaaa-"sv)); + EXPECT(!Unicode::is_type_identifier(""sv)); + EXPECT(!Unicode::is_type_identifier("a"sv)); + EXPECT(!Unicode::is_type_identifier("aa"sv)); + EXPECT(!Unicode::is_type_identifier("aaaaaaaaa"sv)); + EXPECT(!Unicode::is_type_identifier("aaaa-"sv)); } template @@ -104,11 +104,11 @@ template TEST_CASE(parse_unicode_locale_id) { auto fail = [](StringView locale) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); EXPECT(!locale_id.has_value()); }; auto pass = [](StringView locale, Optional expected_language, Optional expected_script, Optional expected_region, Vector expected_variants) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); EXPECT_EQ(locale_id->language_id.language, expected_language); @@ -145,15 +145,15 @@ TEST_CASE(parse_unicode_locale_id_with_unicode_locale_extension) }; auto fail = [](StringView locale) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); EXPECT(!locale_id.has_value()); }; auto pass = [](StringView locale, LocaleExtension const& expected_extension) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); EXPECT_EQ(locale_id->extensions.size(), 1u); - auto const& actual_extension = locale_id->extensions[0].get(); + auto const& actual_extension = locale_id->extensions[0].get(); EXPECT(compare_vectors(actual_extension.attributes, expected_extension.attributes)); EXPECT_EQ(actual_extension.keywords.size(), expected_extension.keywords.size()); @@ -209,15 +209,15 @@ TEST_CASE(parse_unicode_locale_id_with_transformed_extension) }; auto fail = [](StringView locale) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); EXPECT(!locale_id.has_value()); }; auto pass = [](StringView locale, TransformedExtension const& expected_extension) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); EXPECT_EQ(locale_id->extensions.size(), 1u); - auto const& actual_extension = locale_id->extensions[0].get(); + auto const& actual_extension = locale_id->extensions[0].get(); VERIFY(actual_extension.language.has_value() == expected_extension.language.has_value()); if (actual_extension.language.has_value()) { @@ -280,15 +280,15 @@ TEST_CASE(parse_unicode_locale_id_with_other_extension) }; auto fail = [](StringView locale) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); EXPECT(!locale_id.has_value()); }; auto pass = [](StringView locale, OtherExtension const& expected_extension) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); EXPECT_EQ(locale_id->extensions.size(), 1u); - auto const& actual_extension = locale_id->extensions[0].get(); + auto const& actual_extension = locale_id->extensions[0].get(); EXPECT_EQ(actual_extension.key, expected_extension.key); EXPECT_EQ(actual_extension.value, expected_extension.value); }; @@ -314,11 +314,11 @@ TEST_CASE(parse_unicode_locale_id_with_other_extension) TEST_CASE(parse_unicode_locale_id_with_private_use_extension) { auto fail = [](StringView locale) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); EXPECT(!locale_id.has_value()); }; auto pass = [](StringView locale, Vector const& expected_extension) { - auto locale_id = Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); EXPECT(compare_vectors(locale_id->private_use_extensions, expected_extension)); }; @@ -338,7 +338,7 @@ TEST_CASE(parse_unicode_locale_id_with_private_use_extension) TEST_CASE(canonicalize_unicode_locale_id) { auto test = [](StringView locale, StringView expected_canonical_locale) { - auto canonical_locale = Locale::canonicalize_unicode_locale_id(locale); + auto canonical_locale = Unicode::canonicalize_unicode_locale_id(locale); EXPECT_EQ(canonical_locale, expected_canonical_locale); }; @@ -510,8 +510,8 @@ TEST_CASE(canonicalize_unicode_locale_id) TEST_CASE(supports_locale_aliases) { - EXPECT(Locale::is_locale_available("zh"sv)); - EXPECT(Locale::is_locale_available("zh-Hant"sv)); - EXPECT(Locale::is_locale_available("zh-TW"sv)); - EXPECT(Locale::is_locale_available("zh-Hant-TW"sv)); + 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)); } diff --git a/Tests/LibLocale/TestSegmenter.cpp b/Tests/LibUnicode/TestSegmenter.cpp similarity index 92% rename from Tests/LibLocale/TestSegmenter.cpp rename to Tests/LibUnicode/TestSegmenter.cpp index 2b9bf36af4d..403c428f66b 100644 --- a/Tests/LibLocale/TestSegmenter.cpp +++ b/Tests/LibUnicode/TestSegmenter.cpp @@ -10,13 +10,13 @@ #include #include #include -#include +#include template static void test_grapheme_segmentation(StringView string, size_t const (&expected_boundaries)[N]) { Vector boundaries; - auto segmenter = Locale::Segmenter::create(Locale::SegmenterGranularity::Grapheme); + auto segmenter = Unicode::Segmenter::create(Unicode::SegmenterGranularity::Grapheme); segmenter->for_each_boundary(MUST(String::from_utf8(string)), [&](auto boundary) { boundaries.append(boundary); @@ -28,7 +28,7 @@ static void test_grapheme_segmentation(StringView string, size_t const (&expecte TEST_CASE(grapheme_segmentation) { - auto segmenter = Locale::Segmenter::create(Locale::SegmenterGranularity::Grapheme); + auto segmenter = Unicode::Segmenter::create(Unicode::SegmenterGranularity::Grapheme); segmenter->for_each_boundary(String {}, [&](auto i) { dbgln("{}", i); @@ -80,7 +80,7 @@ template static void test_word_segmentation(StringView string, size_t const (&expected_boundaries)[N]) { Vector boundaries; - auto segmenter = Locale::Segmenter::create(Locale::SegmenterGranularity::Word); + auto segmenter = Unicode::Segmenter::create(Unicode::SegmenterGranularity::Word); segmenter->for_each_boundary(MUST(String::from_utf8(string)), [&](auto boundary) { boundaries.append(boundary); @@ -92,7 +92,7 @@ static void test_word_segmentation(StringView string, size_t const (&expected_bo TEST_CASE(word_segmentation) { - auto segmenter = Locale::Segmenter::create(Locale::SegmenterGranularity::Word); + auto segmenter = Unicode::Segmenter::create(Unicode::SegmenterGranularity::Word); segmenter->for_each_boundary(String {}, [&](auto) { VERIFY_NOT_REACHED(); diff --git a/Userland/Libraries/CMakeLists.txt b/Userland/Libraries/CMakeLists.txt index e3ef3b8e29c..f74fc622f70 100644 --- a/Userland/Libraries/CMakeLists.txt +++ b/Userland/Libraries/CMakeLists.txt @@ -18,7 +18,6 @@ add_subdirectory(LibIPC) add_subdirectory(LibJS) add_subdirectory(LibKeyboard) add_subdirectory(LibLine) -add_subdirectory(LibLocale) add_subdirectory(LibMain) add_subdirectory(LibProtocol) add_subdirectory(LibRegex) diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index 9080c8a6e08..6685ad4b807 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -271,10 +271,10 @@ set(SOURCES ) serenity_lib(LibJS js) -target_link_libraries(LibJS PRIVATE LibCore LibCrypto LibFileSystem LibRegex LibSyntax LibUnicode LibTimeZone) +target_link_libraries(LibJS PRIVATE LibCore LibCrypto LibFileSystem LibRegex LibSyntax LibTimeZone) -# Link LibLocale publicly to ensure ICU data (which is in libicudata.a) is available in any process using LibJS. -target_link_libraries(LibJS PUBLIC LibLocale) +# Link LibUnicode publicly to ensure ICU data (which is in libicudata.a) is available in any process using LibJS. +target_link_libraries(LibJS PUBLIC LibUnicode) # TODO: This is probably also needed on RISC-V. if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i.86.*") diff --git a/Userland/Libraries/LibJS/Print.cpp b/Userland/Libraries/LibJS/Print.cpp index 002e646c9d5..c7f57858bce 100644 --- a/Userland/Libraries/LibJS/Print.cpp +++ b/Userland/Libraries/LibJS/Print.cpp @@ -740,7 +740,7 @@ ErrorOr print_intl_date_time_format(JS::PrintContext& print_context, JS::I TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.numbering_system()), seen_objects)); if (date_time_format.hour_cycle.has_value()) { TRY(js_out(print_context, "\n hourCycle: ")); - TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), ::Locale::hour_cycle_to_string(*date_time_format.hour_cycle)), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), Unicode::hour_cycle_to_string(*date_time_format.hour_cycle)), seen_objects)); } TRY(js_out(print_context, "\n timeZone: ")); TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.time_zone()), seen_objects)); @@ -768,7 +768,7 @@ ErrorOr print_intl_date_time_format(JS::PrintContext& print_context, JS::I if (print_value(print_context, JS::Value(*option), seen_objects).is_error()) return JS::throw_completion(JS::js_null()); } else { - auto name = Locale::calendar_pattern_style_to_string(*option); + auto name = Unicode::calendar_pattern_style_to_string(*option); if (print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), name), seen_objects).is_error()) return JS::throw_completion(JS::js_null()); } diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index f4ee12c2520..da5cc364365 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -24,9 +24,9 @@ #include #include #include -#include -#include #include +#include +#include namespace JS { @@ -1156,7 +1156,7 @@ ByteString time_zone_string(double time) // Most implementations seem to prefer the long-form display name of the time zone. Not super important, but we may as well match that behavior. if (auto maybe_offset = TimeZone::get_time_zone_offset(tz_name, AK::UnixDateTime::from_milliseconds_since_epoch(time)); maybe_offset.has_value()) { - if (auto name = Locale::time_zone_display_name(Locale::default_locale(), tz_name, maybe_offset->in_dst, time); name.has_value()) + if (auto name = Unicode::time_zone_display_name(Unicode::default_locale(), tz_name, maybe_offset->in_dst, time); name.has_value()) tz_name = name.release_value(); } else { tz_name = MUST(String::from_utf8(TimeZone::current_time_zone())); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index 0dbb1726611..6c4624fa323 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -49,10 +49,10 @@ bool is_structurally_valid_language_tag(StringView locale) }; // 1. Let lowerLocale be the ASCII-lowercase of locale. - // NOTE: LibLocale's parsing is case-insensitive. + // NOTE: LibUnicode's parsing is case-insensitive. // 2. If lowerLocale cannot be matched by the unicode_locale_id Unicode locale nonterminal, return false. - auto locale_id = ::Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); if (!locale_id.has_value()) return false; @@ -81,9 +81,9 @@ bool is_structurally_valid_language_tag(StringView locale) // 9. If extensions is not the empty String, then for (auto& extension : locale_id->extensions) { char key = extension.visit( - [](::Locale::LocaleExtension const&) { return 'u'; }, - [](::Locale::TransformedExtension const&) { return 't'; }, - [](::Locale::OtherExtension const& ext) { return static_cast(to_ascii_lowercase(ext.key)); }); + [](Unicode::LocaleExtension const&) { return 'u'; }, + [](Unicode::TransformedExtension const&) { return 't'; }, + [](Unicode::OtherExtension const& ext) { return static_cast(to_ascii_lowercase(ext.key)); }); // a. If extensions contains any duplicate singleton subtags, return false. if (unique_keys.set(key) != HashSetResult::InsertedNewEntry) @@ -91,7 +91,7 @@ bool is_structurally_valid_language_tag(StringView locale) // b. Let transformExtension be the longest substring of extensions matched by the transformed_extensions Unicode // locale nonterminal. If there is no such substring, return true. - if (auto* transformed = extension.get_pointer<::Locale::TransformedExtension>()) { + if (auto* transformed = extension.get_pointer()) { // c. Assert: The substring of transformExtension from 0 to 3 is "-t-". // d. Let tPrefix be the substring of transformExtension from 3. @@ -119,7 +119,7 @@ bool is_structurally_valid_language_tag(StringView locale) // 6.2.3 CanonicalizeUnicodeLocaleId ( locale ), https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid String canonicalize_unicode_locale_id(StringView locale) { - return ::Locale::canonicalize_unicode_locale_id(locale); + return Unicode::canonicalize_unicode_locale_id(locale); } // 6.3.1 IsWellFormedCurrencyCode ( currency ), https://tc39.es/ecma402/#sec-iswellformedcurrencycode @@ -267,15 +267,15 @@ Optional lookup_matching_locale_by_prefix(ReadonlySpan re { // 1. For each element locale of requestedLocales, do for (auto locale : requested_locales) { - auto locale_id = ::Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); // a. Let extension be empty. - Optional<::Locale::Extension> extension; + Optional extension; String locale_without_extension; // b. If locale contains a Unicode locale extension sequence, then - if (auto extensions = locale_id->remove_extension_type<::Locale::LocaleExtension>(); !extensions.is_empty()) { + if (auto extensions = locale_id->remove_extension_type(); !extensions.is_empty()) { VERIFY(extensions.size() == 1); // i. Set extension to the Unicode locale extension sequence of locale. @@ -291,7 +291,7 @@ Optional lookup_matching_locale_by_prefix(ReadonlySpan re // d. Repeat, while prefix is not the empty String, while (!prefix.is_empty()) { // i. If availableLocales contains prefix, return the Record { [[locale]]: prefix, [[extension]]: extension }. - if (::Locale::is_locale_available(prefix)) + if (Unicode::is_locale_available(prefix)) return MatchedLocale { MUST(String::from_utf8(prefix)), move(extension) }; // ii. If prefix contains "-" (code unit 0x002D HYPHEN-MINUS), let pos be the index into prefix of the last @@ -322,13 +322,13 @@ Optional lookup_matching_locale_by_best_fit(ReadonlySpan } // 9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, attributes, keywords ), https://tc39.es/ecma402/#sec-insert-unicode-extension-and-canonicalize -String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, Vector attributes, Vector<::Locale::Keyword> keywords) +String insert_unicode_extension_and_canonicalize(Unicode::LocaleID locale, Vector attributes, Vector keywords) { // Note: This implementation differs from the spec in how the extension is inserted. The spec assumes // the input to this method is a string, and is written such that operations are performed on parts - // of that string. LibLocale gives us the parsed locale in a structure, so we can mutate that + // of that string. LibUnicode gives us the parsed locale in a structure, so we can mutate that // structure directly. - locale.extensions.append(::Locale::LocaleExtension { move(attributes), move(keywords) }); + locale.extensions.append(Unicode::LocaleExtension { move(attributes), move(keywords) }); // 10. Return CanonicalizeUnicodeLocaleId(newLocale). return JS::Intl::canonicalize_unicode_locale_id(locale.to_string()); @@ -356,7 +356,7 @@ static auto& find_key_in_value(T& value, StringView key) static Vector available_keyword_values(StringView locale, StringView key) { - auto key_locale_data = ::Locale::available_keyword_values(locale, key); + auto key_locale_data = Unicode::available_keyword_values(locale, key); Vector result; result.ensure_capacity(key_locale_data.size()); @@ -396,7 +396,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti // 4. If r is undefined, set r to the Record { [[locale]]: DefaultLocale(), [[extension]]: empty }. if (!matcher_result.has_value()) - matcher_result = MatchedLocale { MUST(String::from_utf8(::Locale::default_locale())), {} }; + matcher_result = MatchedLocale { MUST(String::from_utf8(Unicode::default_locale())), {} }; // 5. Let foundLocale be r.[[locale]]. auto found_locale = move(matcher_result->locale); @@ -408,12 +408,12 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti // 9. Set result.[[LocaleData]] to foundLocaleData. ResolvedLocale result {}; - Vector<::Locale::Keyword> keywords; + Vector keywords; // 10. If r.[[extension]] is not empty, then if (matcher_result->extension.has_value()) { // a. Let components be UnicodeExtensionComponents(r.[[extension]]). - auto& components = matcher_result->extension->get<::Locale::LocaleExtension>(); + auto& components = matcher_result->extension->get(); // b. Let keywords be components.[[Keywords]]. keywords = move(components.keywords); @@ -422,7 +422,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti // a. Let keywords be a new empty List. // 12. Let supportedKeywords be a new empty List. - Vector<::Locale::Keyword> supported_keywords; + Vector supported_keywords; // 13. For each element key of relevantExtensionKeys, do for (auto const& key : relevant_extension_keys) { @@ -435,7 +435,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti auto value = key_locale_data[0]; // e. Let supportedKeyword be empty. - Optional<::Locale::Keyword> supported_keyword; + Optional supported_keyword; // f. If keywords contains an element whose [[Key]] is key, then if (auto entry = keywords.find_if([&](auto const& entry) { return entry.key == key; }); entry != keywords.end()) { @@ -451,7 +451,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti value = move(requested_value); // b. Set supportedKeyword to the Record { [[Key]]: key, [[Value]]: value }. - supported_keyword = ::Locale::Keyword { MUST(String::from_utf8(key)), move(entry->value) }; + supported_keyword = Unicode::Keyword { MUST(String::from_utf8(key)), move(entry->value) }; } } // iv. Else if keyLocaleData contains "true", then @@ -460,7 +460,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti value = true_string; // 2. Set supportedKeyword to the Record { [[Key]]: key, [[Value]]: "" }. - supported_keyword = ::Locale::Keyword { MUST(String::from_utf8(key)), {} }; + supported_keyword = Unicode::Keyword { MUST(String::from_utf8(key)), {} }; } } @@ -476,7 +476,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti // https://github.com/tc39/ecma402/pull/846#discussion_r1428263375 // ii. Set optionsValue to CanonicalizeUValue(ukey, optionsValue). - *options_string = ::Locale::canonicalize_unicode_extension_values(key, *options_string); + *options_string = Unicode::canonicalize_unicode_extension_values(key, *options_string); // iii. If optionsValue is the empty String, then if (options_string->is_empty()) { @@ -504,7 +504,7 @@ ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOpti // 14. If supportedKeywords is not empty, then if (!supported_keywords.is_empty()) { - auto locale_id = ::Locale::parse_unicode_locale_id(found_locale); + auto locale_id = Unicode::parse_unicode_locale_id(found_locale); VERIFY(locale_id.has_value()); // a. Let supportedAttributes be a new empty List. @@ -535,11 +535,11 @@ ThrowCompletionOr filter_locales(VM& vm, ReadonlySpan requested_ // 4. For each element locale of requestedLocales, do for (auto const& locale : requested_locales) { - auto locale_id = ::Locale::parse_unicode_locale_id(locale); + auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); // a. Let noExtensionsLocale be the String value that is locale with any Unicode locale extension sequences removed. - locale_id->remove_extension_type<::Locale::LocaleExtension>(); + locale_id->remove_extension_type(); auto no_extensions_locale = locale_id->to_string(); Optional match; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h index a0fc8ab8ea6..98b793f6e87 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -33,7 +33,7 @@ struct LocaleOptions { struct MatchedLocale { String locale; - Optional<::Locale::Extension> extension; + Optional extension; }; struct ResolvedLocale { @@ -55,7 +55,7 @@ bool is_well_formed_unit_identifier(StringView unit_identifier); ThrowCompletionOr> canonicalize_locale_list(VM&, Value locales); Optional lookup_matching_locale_by_prefix(ReadonlySpan requested_locales); Optional lookup_matching_locale_by_best_fit(ReadonlySpan requested_locales); -String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, Vector attributes, Vector<::Locale::Keyword> keywords); +String insert_unicode_extension_and_canonicalize(Unicode::LocaleID locale_id, Vector attributes, Vector keywords); ResolvedLocale resolve_locale(ReadonlySpan requested_locales, LocaleOptions const& options, ReadonlySpan relevant_extension_keys); ThrowCompletionOr filter_locales(VM& vm, ReadonlySpan requested_locales, Value options); ThrowCompletionOr coerce_options_to_object(VM&, Value options); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index 4cef412326a..0557d596ab6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -51,7 +51,7 @@ static ThrowCompletionOr> initialize_collator(VM& vm, Col // 11. If collation is not undefined, then if (!collation.is_undefined()) { // a. If collation does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. - if (!::Locale::is_type_identifier(collation.as_string().utf8_string_view())) + if (!Unicode::is_type_identifier(collation.as_string().utf8_string_view())) return vm.throw_completion(ErrorType::OptionIsNotValidValue, collation, "collation"sv); // 12. Set opt.[[co]] to collation. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp index 6ed9c186539..135a280bd37 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp @@ -27,7 +27,7 @@ void DateTimeFormat::visit_edges(Cell::Visitor& visitor) } // 11.5.5 FormatDateTimePattern ( dateTimeFormat, patternParts, x, rangeFormatOptions ), https://tc39.es/ecma402/#sec-formatdatetimepattern -ThrowCompletionOr> format_date_time_pattern(VM& vm, DateTimeFormat& date_time_format, double time) +ThrowCompletionOr> format_date_time_pattern(VM& vm, DateTimeFormat& date_time_format, double time) { // 1. Let x be TimeClip(x). time = time_clip(time); @@ -40,7 +40,7 @@ ThrowCompletionOr> format_date_time_ } // 11.5.6 PartitionDateTimePattern ( dateTimeFormat, x ), https://tc39.es/ecma402/#sec-partitiondatetimepattern -ThrowCompletionOr> partition_date_time_pattern(VM& vm, DateTimeFormat& date_time_format, double time) +ThrowCompletionOr> partition_date_time_pattern(VM& vm, DateTimeFormat& date_time_format, double time) { // 1. Let patternParts be PartitionPattern(dateTimeFormat.[[Pattern]]). // 2. Let result be ? FormatDateTimePattern(dateTimeFormat, patternParts, x, undefined). @@ -107,7 +107,7 @@ ThrowCompletionOr> format_date_time_to_parts(VM& vm, DateTim } // 11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat, x, y ), https://tc39.es/ecma402/#sec-partitiondatetimerangepattern -ThrowCompletionOr> partition_date_time_range_pattern(VM& vm, DateTimeFormat& date_time_format, double start, double end) +ThrowCompletionOr> partition_date_time_range_pattern(VM& vm, DateTimeFormat& date_time_format, double start, double end) { // 1. Let x be TimeClip(x). start = time_clip(start); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h index 72ba2c3bcb4..6b7c44256d8 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h @@ -14,17 +14,17 @@ #include #include #include -#include +#include namespace JS::Intl { class DateTimeFormat final : public Object - , public ::Locale::CalendarPattern { + , public Unicode::CalendarPattern { JS_OBJECT(DateTimeFormat, Object); JS_DECLARE_ALLOCATOR(DateTimeFormat); - using Patterns = ::Locale::CalendarPattern; + using Patterns = Unicode::CalendarPattern; public: static constexpr auto relevant_extension_keys() @@ -49,48 +49,48 @@ public: void set_time_zone(String time_zone) { m_time_zone = move(time_zone); } bool has_date_style() const { return m_date_style.has_value(); } - Optional<::Locale::DateTimeStyle> const& date_style() const { return m_date_style; } - StringView date_style_string() const { return ::Locale::date_time_style_to_string(*m_date_style); } - void set_date_style(StringView style) { m_date_style = ::Locale::date_time_style_from_string(style); } + Optional const& date_style() const { return m_date_style; } + StringView date_style_string() const { return Unicode::date_time_style_to_string(*m_date_style); } + void set_date_style(StringView style) { m_date_style = Unicode::date_time_style_from_string(style); } bool has_time_style() const { return m_time_style.has_value(); } - Optional<::Locale::DateTimeStyle> const& time_style() const { return m_time_style; } - StringView time_style_string() const { return ::Locale::date_time_style_to_string(*m_time_style); } - void set_time_style(StringView style) { m_time_style = ::Locale::date_time_style_from_string(style); } + Optional const& time_style() const { return m_time_style; } + StringView time_style_string() const { return Unicode::date_time_style_to_string(*m_time_style); } + void set_time_style(StringView style) { m_time_style = Unicode::date_time_style_from_string(style); } NativeFunction* bound_format() const { return m_bound_format; } void set_bound_format(NativeFunction* bound_format) { m_bound_format = bound_format; } - ::Locale::DateTimeFormat const& formatter() const { return *m_formatter; } - void set_formatter(NonnullOwnPtr<::Locale::DateTimeFormat> formatter) { m_formatter = move(formatter); } + Unicode::DateTimeFormat const& formatter() const { return *m_formatter; } + void set_formatter(NonnullOwnPtr formatter) { m_formatter = move(formatter); } private: DateTimeFormat(Object& prototype); virtual void visit_edges(Visitor&) override; - String m_locale; // [[Locale]] - String m_calendar; // [[Calendar]] - String m_numbering_system; // [[NumberingSystem]] - String m_time_zone; // [[TimeZone]] - Optional<::Locale::DateTimeStyle> m_date_style; // [[DateStyle]] - Optional<::Locale::DateTimeStyle> m_time_style; // [[TimeStyle]] - GCPtr m_bound_format; // [[BoundFormat]] + String m_locale; // [[Locale]] + String m_calendar; // [[Calendar]] + String m_numbering_system; // [[NumberingSystem]] + String m_time_zone; // [[TimeZone]] + Optional m_date_style; // [[DateStyle]] + Optional m_time_style; // [[TimeStyle]] + GCPtr m_bound_format; // [[BoundFormat]] // Non-standard. Stores the ICU date-time formatter for the Intl object's formatting options. - OwnPtr<::Locale::DateTimeFormat> m_formatter; + OwnPtr m_formatter; }; -ThrowCompletionOr> format_date_time_pattern(VM&, DateTimeFormat&, double time); -ThrowCompletionOr> partition_date_time_pattern(VM&, DateTimeFormat&, double time); +ThrowCompletionOr> format_date_time_pattern(VM&, DateTimeFormat&, double time); +ThrowCompletionOr> partition_date_time_pattern(VM&, DateTimeFormat&, double time); ThrowCompletionOr format_date_time(VM&, DateTimeFormat&, double time); ThrowCompletionOr> format_date_time_to_parts(VM&, DateTimeFormat&, double time); -ThrowCompletionOr> partition_date_time_range_pattern(VM&, DateTimeFormat&, double start, double end); +ThrowCompletionOr> partition_date_time_range_pattern(VM&, DateTimeFormat&, double start, double end); ThrowCompletionOr format_date_time_range(VM&, DateTimeFormat&, double start, double end); ThrowCompletionOr> format_date_time_range_to_parts(VM&, DateTimeFormat&, double start, double end); template -ThrowCompletionOr for_each_calendar_field(VM& vm, ::Locale::CalendarPattern& pattern, Callback&& callback) +ThrowCompletionOr for_each_calendar_field(VM& vm, Unicode::CalendarPattern& pattern, Callback&& callback) { constexpr auto narrow_short_long = AK::Array { "narrow"sv, "short"sv, "long"sv }; constexpr auto two_digit_numeric = AK::Array { "2-digit"sv, "numeric"sv }; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp index 493ecd7e13c..b6c6bff3577 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include namespace JS::Intl { @@ -108,7 +108,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // 8. If calendar is not undefined, then if (!calendar.is_undefined()) { // a. If calendar cannot be matched by the type Unicode locale nonterminal, throw a RangeError exception. - if (!::Locale::is_type_identifier(calendar.as_string().utf8_string_view())) + if (!Unicode::is_type_identifier(calendar.as_string().utf8_string_view())) return vm.throw_completion(ErrorType::OptionIsNotValidValue, calendar, "calendar"sv); } @@ -121,7 +121,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // 11. If numberingSystem is not undefined, then if (!numbering_system.is_undefined()) { // a. If numberingSystem cannot be matched by the type Unicode locale nonterminal, throw a RangeError exception. - if (!::Locale::is_type_identifier(numbering_system.as_string().utf8_string_view())) + if (!Unicode::is_type_identifier(numbering_system.as_string().utf8_string_view())) return vm.throw_completion(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); } @@ -162,7 +162,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // 23. Let dataLocale be r.[[dataLocale]]. // 24. Let dataLocaleData be localeData.[[]]. - Optional<::Locale::HourCycle> hour_cycle_value; + Optional hour_cycle_value; Optional hour12_value; // 25. If hour12 is true, then @@ -170,7 +170,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // 26. Else if hour12 is false, then // a. Let hc be dataLocaleData.[[hourCycle24]]. if (hour12.is_boolean()) { - // NOTE: We let LibLocale figure out the appropriate hour cycle. + // NOTE: We let LibUnicode figure out the appropriate hour cycle. hour12_value = hour12.as_bool(); } // 27. Else, @@ -180,11 +180,11 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // b. Let hc be r.[[hc]]. if (auto* resolved_hour_cycle = result.hc.get_pointer()) - hour_cycle_value = ::Locale::hour_cycle_from_string(*resolved_hour_cycle); + hour_cycle_value = Unicode::hour_cycle_from_string(*resolved_hour_cycle); // c. If hc is null, set hc to dataLocaleData.[[hourCycle]]. if (!hour_cycle_value.has_value()) - hour_cycle_value = ::Locale::default_hour_cycle(date_time_format->locale()); + hour_cycle_value = Unicode::default_hour_cycle(date_time_format->locale()); } // 28. Set dateTimeFormat.[[HourCycle]] to hc. @@ -250,7 +250,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, time_zone = MUST(String::formatted("GMT{}", time_zone)); // 36. Let formatOptions be a new Record. - ::Locale::CalendarPattern format_options {}; + Unicode::CalendarPattern format_options {}; // 37. Set formatOptions.[[hourCycle]] to hc. format_options.hour_cycle = hour_cycle_value; @@ -288,7 +288,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // d. Set formatOptions.[[]] to value. if (!value.is_undefined()) { - option = ::Locale::calendar_pattern_style_from_string(value.as_string().utf8_string_view()); + option = Unicode::calendar_pattern_style_from_string(value.as_string().utf8_string_view()); // e. If value is not undefined, then // i. Set hasExplicitFormatComponents to true. @@ -338,7 +338,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // d. Let styles be dataLocaleData.[[styles]].[[]]. // e. Let bestFormat be DateTimeStyleFormat(dateStyle, timeStyle, styles). - auto formatter = ::Locale::DateTimeFormat::create_for_date_and_time_style( + auto formatter = Unicode::DateTimeFormat::create_for_date_and_time_style( date_time_format->locale(), time_zone, format_options.hour_cycle, @@ -390,7 +390,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // i. For each property name prop of « "year", "month", "day" », do auto set_property_value = [&](auto& value) { // 1. Set formatOptions.[[]] to "numeric". - value = ::Locale::CalendarPatternStyle::Numeric; + value = Unicode::CalendarPatternStyle::Numeric; }; set_property_value(format_options.year); @@ -403,7 +403,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // i. For each property name prop of « "hour", "minute", "second" », do auto set_property_value = [&](auto& value) { // 1. Set formatOptions.[[]] to "numeric". - value = ::Locale::CalendarPatternStyle::Numeric; + value = Unicode::CalendarPatternStyle::Numeric; }; set_property_value(format_options.hour); @@ -416,7 +416,7 @@ ThrowCompletionOr> create_date_time_format(VM& vm, // i. Let bestFormat be BasicFormatMatcher(formatOptions, formats). // h. Else, // i. Let bestFormat be BestFitFormatMatcher(formatOptions, formats). - auto formatter = ::Locale::DateTimeFormat::create_for_pattern_options( + auto formatter = Unicode::DateTimeFormat::create_for_pattern_options( date_time_format->locale(), time_zone, format_options); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp index 709c36ff373..a91de5ea53a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -180,15 +180,15 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) MUST(options->create_data_property_or_throw(vm.names.timeZone, PrimitiveString::create(vm, date_time_format->time_zone()))); if (date_time_format->hour_cycle.has_value()) { - MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, ::Locale::hour_cycle_to_string(*date_time_format->hour_cycle)))); + MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, Unicode::hour_cycle_to_string(*date_time_format->hour_cycle)))); switch (*date_time_format->hour_cycle) { - case ::Locale::HourCycle::H11: - case ::Locale::HourCycle::H12: + case Unicode::HourCycle::H11: + case Unicode::HourCycle::H12: MUST(options->create_data_property_or_throw(vm.names.hour12, Value(true))); break; - case ::Locale::HourCycle::H23: - case ::Locale::HourCycle::H24: + case Unicode::HourCycle::H23: + case Unicode::HourCycle::H24: MUST(options->create_data_property_or_throw(vm.names.hour12, Value(false))); break; } @@ -204,7 +204,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) if constexpr (IsIntegral) { MUST(options->create_data_property_or_throw(property, Value(*option))); } else { - auto name = ::Locale::calendar_pattern_style_to_string(*option); + auto name = Unicode::calendar_pattern_style_to_string(*option); MUST(options->create_data_property_or_throw(property, PrimitiveString::create(vm, name))); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp index a3e5c3923bc..6ea371bfd85 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp @@ -84,7 +84,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // 1. If type is "language", then if (type == DisplayNames::Type::Language) { // a. If code does not match the unicode_language_id production, throw a RangeError exception. - if (!::Locale::parse_unicode_language_id(code).has_value()) + if (!Unicode::parse_unicode_language_id(code).has_value()) return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "language"sv); // b. If IsStructurallyValidLanguageTag(code) is false, throw a RangeError exception. @@ -99,7 +99,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // 2. If type is "region", then if (type == DisplayNames::Type::Region) { // a. If code does not match the unicode_region_subtag production, throw a RangeError exception. - if (!::Locale::is_unicode_region_subtag(code)) + if (!Unicode::is_unicode_region_subtag(code)) return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "region"sv); // b. Return the ASCII-uppercase of code. @@ -109,7 +109,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // 3. If type is "script", then if (type == DisplayNames::Type::Script) { // a. If code does not match the unicode_script_subtag production, throw a RangeError exception. - if (!::Locale::is_unicode_script_subtag(code)) + if (!Unicode::is_unicode_script_subtag(code)) return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "script"sv); // Assert: The length of code is 4, and every code unit of code represents an ASCII letter (0x0041 through 0x005A and 0x0061 through 0x007A, both inclusive). @@ -125,7 +125,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // 4. If type is "calendar", then if (type == DisplayNames::Type::Calendar) { // a. If code does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. - if (!::Locale::is_type_identifier(code)) + if (!Unicode::is_type_identifier(code)) return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "calendar"sv); // b. If code uses any of the backwards compatibility syntax described in Unicode Technical Standard #35 LDML § 3.3 BCP 47 Conformance, throw a RangeError exception. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h index 905ab331678..0d3e903af05 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h @@ -10,8 +10,8 @@ #include #include #include -#include -#include +#include +#include namespace JS::Intl { @@ -41,9 +41,9 @@ public: String const& locale() const { return m_locale; } void set_locale(String locale) { m_locale = move(locale); } - ::Locale::Style style() const { return m_style; } - void set_style(StringView style) { m_style = ::Locale::style_from_string(style); } - StringView style_string() const { return ::Locale::style_to_string(m_style); } + Unicode::Style style() const { return m_style; } + void set_style(StringView style) { m_style = Unicode::style_from_string(style); } + StringView style_string() const { return Unicode::style_to_string(m_style); } Type type() const { return m_type; } void set_type(StringView type); @@ -54,18 +54,18 @@ public: StringView fallback_string() const; bool has_language_display() const { return m_language_display.has_value(); } - ::Locale::LanguageDisplay language_display() const { return *m_language_display; } - void set_language_display(StringView language_display) { m_language_display = ::Locale::language_display_from_string(language_display); } - StringView language_display_string() const { return ::Locale::language_display_to_string(*m_language_display); } + Unicode::LanguageDisplay language_display() const { return *m_language_display; } + void set_language_display(StringView language_display) { m_language_display = Unicode::language_display_from_string(language_display); } + StringView language_display_string() const { return Unicode::language_display_to_string(*m_language_display); } private: DisplayNames(Object& prototype); - String m_locale; // [[Locale]] - ::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]] - Type m_type { Type::Invalid }; // [[Type]] - Fallback m_fallback { Fallback::Invalid }; // [[Fallback]] - Optional<::Locale::LanguageDisplay> m_language_display; // [[LanguageDisplay]] + String m_locale; // [[Locale]] + Unicode::Style m_style { Unicode::Style::Long }; // [[Style]] + Type m_type { Type::Invalid }; // [[Type]] + Fallback m_fallback { Fallback::Invalid }; // [[Fallback]] + Optional m_language_display; // [[LanguageDisplay]] }; ThrowCompletionOr canonical_code_for_display_names(VM&, DisplayNames::Type, StringView code); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index 95101057d8f..6d986cce881 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -142,7 +142,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of) auto options = vm.argument(1); // 1. Let availableLocales be %DisplayNames%.[[AvailableLocales]]. - // No-op, availability of each requested locale is checked via ::Locale::is_locale_available() + // No-op, availability of each requested locale is checked via Unicode::is_locale_available() // 2. Let requestedLocales be ? CanonicalizeLocaleList(locales). auto requested_locales = TRY(canonicalize_locale_list(vm, locales)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 89c7aac6263..585b5d7eca3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -57,22 +57,22 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) switch (display_names->type()) { case DisplayNames::Type::Language: - result = ::Locale::language_display_name(display_names->locale(), code_string, display_names->language_display()); + result = Unicode::language_display_name(display_names->locale(), code_string, display_names->language_display()); break; case DisplayNames::Type::Region: - result = ::Locale::region_display_name(display_names->locale(), code_string); + result = Unicode::region_display_name(display_names->locale(), code_string); break; case DisplayNames::Type::Script: - result = ::Locale::script_display_name(display_names->locale(), code_string); + result = Unicode::script_display_name(display_names->locale(), code_string); break; case DisplayNames::Type::Currency: - result = ::Locale::currency_display_name(display_names->locale(), code_string, display_names->style()); + result = Unicode::currency_display_name(display_names->locale(), code_string, display_names->style()); break; case DisplayNames::Type::Calendar: - result = ::Locale::calendar_display_name(display_names->locale(), code_string); + result = Unicode::calendar_display_name(display_names->locale(), code_string); break; case DisplayNames::Type::DateTimeField: - result = ::Locale::date_time_field_display_name(display_names->locale(), code_string, display_names->style()); + result = Unicode::date_time_field_display_name(display_names->locale(), code_string, display_names->style()); break; default: VERIFY_NOT_REACHED(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index 36e5be8ee1c..f6ec6e903b4 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -735,7 +735,7 @@ Vector list_format_parts(VM& vm, DurationFormat const& durat } // 5. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). - auto locale_list_style = ::Locale::style_to_string(static_cast<::Locale::Style>(list_style)); + auto locale_list_style = Unicode::style_to_string(static_cast(list_style)); MUST(list_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, locale_list_style))); // 6. Let lf be ! Construct(%ListFormat%, « durationFormat.[[Locale]], lfOpts »). @@ -925,7 +925,7 @@ Vector partition_duration_format_pattern(VM& vm, DurationFor MUST(number_format_options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format_unit))); // 8. Perform ! CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style). - auto locale_style = ::Locale::style_to_string(static_cast<::Locale::Style>(style)); + auto locale_style = Unicode::style_to_string(static_cast(style)); MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, locale_style))); // 9. Let nf be ! Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »). diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h index 667e96a2f58..39780b83298 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -36,9 +36,9 @@ public: TwoDigit, Fractional, }; - static_assert(to_underlying(ValueStyle::Long) == to_underlying(::Locale::Style::Long)); - static_assert(to_underlying(ValueStyle::Short) == to_underlying(::Locale::Style::Short)); - static_assert(to_underlying(ValueStyle::Narrow) == to_underlying(::Locale::Style::Narrow)); + static_assert(to_underlying(ValueStyle::Long) == to_underlying(Unicode::Style::Long)); + static_assert(to_underlying(ValueStyle::Short) == to_underlying(Unicode::Style::Short)); + static_assert(to_underlying(ValueStyle::Narrow) == to_underlying(Unicode::Style::Narrow)); enum class Display { Auto, diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index 0f2b38c840e..ec683a81a06 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -70,7 +70,7 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Fun // 7. If numberingSystem is not undefined, then if (!numbering_system.is_undefined()) { // a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. - if (!::Locale::is_type_identifier(numbering_system.as_string().utf8_string_view())) + if (!Unicode::is_type_identifier(numbering_system.as_string().utf8_string_view())) return vm.throw_completion(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); } @@ -94,7 +94,7 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Fun // 13. Let dataLocale be durationFormat.[[DataLocale]]. // 14. Let dataLocaleData be durationFormat.[[LocaleData]].[[]]. // 15. Let digitalFormat be dataLocaleData.[[DigitalFormat]]. - auto digital_format = ::Locale::digital_format(duration_format->locale()); + auto digital_format = Unicode::digital_format(duration_format->locale()); // 16. Let twoDigitHours be digitalFormat.[[TwoDigitHours]]. // 17. Set durationFormat.[[TwoDigitHours]] to twoDigitHours. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp index fb369cf48f3..52e5ec8d237 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp @@ -21,11 +21,11 @@ #include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include namespace JS::Intl { @@ -124,22 +124,22 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of) // 2. If key is "calendar", then if (key == "calendar"sv) { // a. Let list be ! AvailableCanonicalCalendars( ). - list = ::Locale::available_calendars().span(); + list = Unicode::available_calendars().span(); } // 3. Else if key is "collation", then else if (key == "collation"sv) { // a. Let list be ! AvailableCanonicalCollations( ). - list = ::Locale::available_collations().span(); + list = Unicode::available_collations().span(); } // 4. Else if key is "currency", then else if (key == "currency"sv) { // a. Let list be ! AvailableCanonicalCurrencies( ). - list = ::Locale::available_currencies().span(); + list = Unicode::available_currencies().span(); } // 5. Else if key is "numberingSystem", then else if (key == "numberingSystem"sv) { // a. Let list be ! AvailableCanonicalNumberingSystems( ). - list = ::Locale::available_number_systems().span(); + list = Unicode::available_number_systems().span(); } // 6. Else if key is "timeZone", then else if (key == "timeZone"sv) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index 4cd76c77bb9..90c5ad230b2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace JS::Intl { @@ -22,7 +22,7 @@ ListFormat::ListFormat(Object& prototype) } // 13.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist -Vector<::Locale::ListFormat::Partition> create_parts_from_list(ListFormat const& list_format, ReadonlySpan list) +Vector create_parts_from_list(ListFormat const& list_format, ReadonlySpan list) { return list_format.formatter().format_to_parts(list); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h index 6e1f0eb8165..e83e394c1d8 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include namespace JS::Intl { @@ -33,29 +33,29 @@ public: String const& locale() const { return m_locale; } void set_locale(String locale) { m_locale = move(locale); } - ::Locale::ListFormatType type() const { return m_type; } - void set_type(StringView type) { m_type = ::Locale::list_format_type_from_string(type); } - StringView type_string() const { return ::Locale::list_format_type_to_string(m_type); } + Unicode::ListFormatType type() const { return m_type; } + void set_type(StringView type) { m_type = Unicode::list_format_type_from_string(type); } + StringView type_string() const { return Unicode::list_format_type_to_string(m_type); } - ::Locale::Style style() const { return m_style; } - void set_style(StringView style) { m_style = ::Locale::style_from_string(style); } - StringView style_string() const { return ::Locale::style_to_string(m_style); } + Unicode::Style style() const { return m_style; } + void set_style(StringView style) { m_style = Unicode::style_from_string(style); } + StringView style_string() const { return Unicode::style_to_string(m_style); } - ::Locale::ListFormat const& formatter() const { return *m_formatter; } - void set_formatter(NonnullOwnPtr<::Locale::ListFormat> formatter) { m_formatter = move(formatter); } + Unicode::ListFormat const& formatter() const { return *m_formatter; } + void set_formatter(NonnullOwnPtr formatter) { m_formatter = move(formatter); } private: explicit ListFormat(Object& prototype); - String m_locale; // [[Locale]] - ::Locale::ListFormatType m_type { ::Locale::ListFormatType::Conjunction }; // [[Type]] - ::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]] + String m_locale; // [[Locale]] + Unicode::ListFormatType m_type { Unicode::ListFormatType::Conjunction }; // [[Type]] + Unicode::Style m_style { Unicode::Style::Long }; // [[Style]] // Non-standard. Stores the ICU list formatter for the Intl object's formatting options. - OwnPtr<::Locale::ListFormat> m_formatter; + OwnPtr m_formatter; }; -Vector<::Locale::ListFormat::Partition> create_parts_from_list(ListFormat const&, ReadonlySpan list); +Vector create_parts_from_list(ListFormat const&, ReadonlySpan list); String format_list(ListFormat const&, ReadonlySpan list); NonnullGCPtr format_list_to_parts(VM&, ListFormat const&, ReadonlySpan list); ThrowCompletionOr> string_list_from_iterable(VM&, Value iterable); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index 7bd9ecd0236..6430df79d67 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -91,7 +91,7 @@ ThrowCompletionOr> ListFormatConstructor::construct(Functio // 14. Let resolvedLocaleData be r.[[LocaleData]]. // 15. Let dataLocaleTypes be resolvedLocaleData.[[]]. // 16. Set listFormat.[[Templates]] to dataLocaleTypes.[[