From adb762ee48c10f0f07d6a0f314b1d80ef74ec600 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 12 Jan 2022 17:57:45 -0500 Subject: [PATCH] LibJS: Add FIXME regarding [[LanguageDisplay]] internal slot handling This is supposed to work as follows (grabbed from SpiderMonkey): > opt = { type: "language", languageDisplay: "dialect" }; > new Intl.DisplayNames([], opt).of("en-US"); "American English" > opt = { type: "language", languageDisplay: "standard" }; > new Intl.DisplayNames([], opt).of("en-US"); "English (United States)" We currently display the "dialect" variant. We will need to figure out how to display the "standard" variant. I think the way it works is that we take the display names of "en" (language) and "US" (region) and format them according to this pattern in localeDisplayNames.json: "localeDisplayNames": { "localeDisplayPattern": { "localePattern": "{0} ({1})", }, }, But I'd like to confirm this before implementing it. --- Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 8633841cea..0c51b3717b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -54,6 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) switch (display_names->type()) { case DisplayNames::Type::Language: + // FIXME: Handle the [[LanguageDisplay]] internal slot once we know where that data comes from. result = Unicode::get_locale_language_mapping(display_names->locale(), code.as_string().string()); break; case DisplayNames::Type::Region: