1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:57:34 +00:00

LibJS: Use Intl.PluralRules within Intl.NumberFormat

This also allows removing a bit of a BigInt hack to resolve plurality of
BigInt numbers (because the AOs used in ResolvePlural support BigInt,
wherease the naive Unicode::select_pattern_with_plurality did not).

We use cardinal form here; the number format patterns in the CLDR align
with the cardinal form of the plural rules.
This commit is contained in:
Timothy Flynn 2022-07-08 12:05:09 -04:00 committed by Linus Groh
parent 6d9b779757
commit 5b68c1a06c
2 changed files with 12 additions and 16 deletions

View file

@ -228,7 +228,7 @@ String format_numeric(GlobalObject& global_object, NumberFormat& number_format,
Array* format_numeric_to_parts(GlobalObject& global_object, NumberFormat& number_format, Value number);
RawFormatResult to_raw_precision(GlobalObject& global_object, Value number, int min_precision, int max_precision);
RawFormatResult to_raw_fixed(GlobalObject& global_object, Value number, int min_fraction, int max_fraction);
Optional<Variant<StringView, String>> get_number_format_pattern(NumberFormat& number_format, Value number, Unicode::NumberFormat& found_pattern);
Optional<Variant<StringView, String>> get_number_format_pattern(GlobalObject& global_object, NumberFormat& number_format, Value number, Unicode::NumberFormat& found_pattern);
Optional<StringView> get_notation_sub_pattern(NumberFormat& number_format, int exponent);
int compute_exponent(GlobalObject& global_object, NumberFormat& number_format, Value number);
int compute_exponent_for_magnitude(NumberFormat& number_format, int magnitude);