diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 3e067c17d1..598c9c4dad 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -83,6 +83,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) result = Unicode::get_locale_territory_mapping(display_names->locale(), code.as_string().string()); break; case DisplayNames::Type::Script: + result = Unicode::get_locale_script_mapping(display_names->locale(), code.as_string().string()); break; case DisplayNames::Type::Currency: break; diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js index 314ec0599c..7b2385ab2e 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js @@ -58,4 +58,19 @@ describe("correct behavior", () => { expect(es419.of("AA")).toBe("AA"); expect(zhHant.of("AA")).toBe("AA"); }); + + test("option type script", () => { + const en = new Intl.DisplayNames("en", { type: "script" }); + expect(en.of("Latn")).toBe("Latin"); + + const es419 = new Intl.DisplayNames("es-419", { type: "script" }); + expect(es419.of("Latn")).toBe("latín"); + + const zhHant = new Intl.DisplayNames(["zh-Hant"], { type: "script" }); + expect(zhHant.of("Latn")).toBe("拉丁文"); + + expect(en.of("Aaaa")).toBe("Aaaa"); + expect(es419.of("Aaaa")).toBe("Aaaa"); + expect(zhHant.of("Aaaa")).toBe("Aaaa"); + }); });