-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Labels
c: numbersComponent: numbers, currency, unitsComponent: numbers, currency, unitss: commentStatus: more info is needed to move forwardStatus: more info is needed to move forward
Description
Time and time again, programmers are confused about how to use Intl.PluralRules, especially in ways that relate to rendered digits, like how to take the plural form of 1 versus 1.00 versus 1K.
In the ICU implementation, to solve this problem, we allow users to pass a FormattedNumber, the output of NumberFormatter, into PluralRules.
Here's a draft of how this could look in ECMAScript:
const fmt = new Intl.NumberFormat("fr-FR", {
notation: "compact"
});
const { string, pluralForm } = fmt.formatSelect(2.5e6);
console.log(string, pluralForm);
// "2.5 M" manyIntl.PluralRules would still be useful for the case where you don't care about the rendered output, but the new API on Intl.NumberFormat would help clarify how to get the effective plural form for a formatted number.
The new APIs:
formatSelectreturns{ string, pluralForm }formatToPartsSelect(orformatSelectToParts) returns{ parts, pluralForm }
Thoughts?
Metadata
Metadata
Assignees
Labels
c: numbersComponent: numbers, currency, unitsComponent: numbers, currency, unitss: commentStatus: more info is needed to move forwardStatus: more info is needed to move forward
Type
Projects
Status
Previously Discussed