mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS: Extend Intl.DisplayNames.of to support script tags
This commit is contained in:
parent
0f02def3c2
commit
a029e3d38a
Notes:
sideshowbarker
2024-07-18 05:13:48 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/a029e3d38af Pull-request: https://github.com/SerenityOS/serenity/pull/9622 Reviewed-by: https://github.com/linusg
2 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue