1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibJS: Add an overload of ResolvePlural for use without PluralRules

The NumberFormat spec casually indicates the need for a PluralRules
object without explicity saying so, with text such as:

"which may depend on x in languages having different plural forms."

Other implementations actually do create a PluralRules object to resolve
those cases with ResolvePlural. However, ResolvePlural doesn't need much
from PluralRules to operate, so this can be abstracted out for use in
NumberFormat without the need to allocate a PluralRules instance.
This commit is contained in:
Timothy Flynn 2022-07-08 11:52:18 -04:00 committed by Linus Groh
parent 1fc87d1529
commit 6d9b779757
2 changed files with 9 additions and 3 deletions

View file

@ -32,5 +32,6 @@ private:
Unicode::PluralOperands get_operands(String const& string);
Unicode::PluralCategory plural_rule_select(StringView locale, Unicode::PluralForm type, Value number, Unicode::PluralOperands operands);
Unicode::PluralCategory resolve_plural(GlobalObject& global_object, PluralRules const& plural_rules, Value number);
Unicode::PluralCategory resolve_plural(GlobalObject& global_object, NumberFormatBase const& number_format, Unicode::PluralForm type, Value number);
}