mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
LibJS: Extend Intl.DisplayNames.of to support currency tags
This commit is contained in:
parent
8b93d51212
commit
86b99fd9a6
Notes:
sideshowbarker
2024-07-18 05:13:36 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/86b99fd9a6c Pull-request: https://github.com/SerenityOS/serenity/pull/9622 Reviewed-by: https://github.com/linusg
@ -86,6 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
||||
result = Unicode::get_locale_script_mapping(display_names->locale(), code.as_string().string());
|
||||
break;
|
||||
case DisplayNames::Type::Currency:
|
||||
result = Unicode::get_locale_currency_mapping(display_names->locale(), code.as_string().string());
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -73,4 +73,19 @@ describe("correct behavior", () => {
|
||||
expect(es419.of("Aaaa")).toBe("Aaaa");
|
||||
expect(zhHant.of("Aaaa")).toBe("Aaaa");
|
||||
});
|
||||
|
||||
test("option type currency", () => {
|
||||
const en = new Intl.DisplayNames("en", { type: "currency" });
|
||||
expect(en.of("USD")).toBe("US Dollar");
|
||||
|
||||
const es419 = new Intl.DisplayNames("es-419", { type: "currency" });
|
||||
expect(es419.of("USD")).toBe("dólar estadounidense");
|
||||
|
||||
const zhHant = new Intl.DisplayNames(["zh-Hant"], { type: "currency" });
|
||||
expect(zhHant.of("USD")).toBe("美元");
|
||||
|
||||
expect(en.of("AAA")).toBe("AAA");
|
||||
expect(es419.of("AAA")).toBe("AAA");
|
||||
expect(zhHant.of("AAA")).toBe("AAA");
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user