mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +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: a029e3d38a
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());
|
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