Closed Bug 1543658 Opened 5 years ago Closed 5 years ago

Missing rounding mode in internal UNumberFormat in Intl.PluralRules?

Categories

(Core :: JavaScript: Internationalization API, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox68 --- wontfix
firefox69 --- wontfix
firefox70 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file)

new Intl.PluralRules("en", {maximumFractionDigits:0}).select(0.5) currently returns "other". But given that new Intl.NumberFormat("en", {maximumFractionDigits:0}).format(0.5) returns "1", is the correct result actually "one"?

Also compare, new Intl.PluralRules("en", {maximumFractionDigits:0}).select(0) returns "other", whereas new Intl.PluralRules("en", {maximumFractionDigits:0}).select(1) returns "one".

https://tc39.github.io/ecma402/#sec-pluralruleselect doesn't describe if n or operands should be used to select the correct plural representation:

When the PluralRuleSelect abstract operation is called with four arguments, it performs an implementation-dependent algorithm to map n to the appropriate plural representation of the Plural Rules Operands Record operands by selecting the rules denoted by type for the corresponding locale, or the String value "other".

So, seems like we respect minimumFractionDigits, but not maximumFractionDigits? :)

new Intl.PluralRules("en", {minimumFractionDigits:0}).select(1) // one
new Intl.PluralRules("en", {minimumFractionDigits:1}).select(1) // other

I'd say we should respect maximum as well.

The priority flag is not set for this bug.
:Waldo, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jwalden)

Yeah, I'm inclined to say we should be doing round-to-nearest-even everywhere. PluralRules delegates a bunch of stuff to NumberFormat handling already, and this seems like the sort of thing where the algorithm should be following suit.

Flags: needinfo?(jwalden)
Priority: -- → P2
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

Pushed by dvarga@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/79e15e776159
Add missing rounding-mode to Intl.PluralRules. r=jwalden

Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70

Since the status are different for nightly and release, what's the status for beta?
For more information, please visit auto_nag documentation.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: