mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
LibJS: Extend Intl.DisplayNames.of to support script tags
This commit is contained in:
parent
0f02def3c2
commit
a029e3d38a
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());
|
result = Unicode::get_locale_territory_mapping(display_names->locale(), code.as_string().string());
|
||||||
break;
|
break;
|
||||||
case DisplayNames::Type::Script:
|
case DisplayNames::Type::Script:
|
||||||
|
result = Unicode::get_locale_script_mapping(display_names->locale(), code.as_string().string());
|
||||||
break;
|
break;
|
||||||
case DisplayNames::Type::Currency:
|
case DisplayNames::Type::Currency:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,4 +58,19 @@ describe("correct behavior", () => {
|
||||||
expect(es419.of("AA")).toBe("AA");
|
expect(es419.of("AA")).toBe("AA");
|
||||||
expect(zhHant.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…
Add table
Add a link
Reference in a new issue