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.
This commit is contained in:
Timothy Flynn 2022-01-12 17:57:45 -05:00 committed by Linus Groh
parent 8126cb2545
commit adb762ee48
Notes: sideshowbarker 2024-07-17 20:57:09 +09:00

View File

@ -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: