-
Notifications
You must be signed in to change notification settings - Fork 112
Normative: Add [[CompactDisplay]] slot to Intl.PluralRules #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normative: Add [[CompactDisplay]] slot to Intl.PluralRules #1019
Conversation
This PR allows implementations to take into account potential
differences between the short compact form ("5K") and long form ("5
thousand") when determining the correct plural form to use.
|
note: the potentially controversial decision here is to have |
| PluralRuleSelect ( | ||
| _locale_: a language tag, | ||
| _type_: *"cardinal"* or *"ordinal"*, | ||
| _notation_: a String, | ||
| _pluralRules_: an Intl.PluralRules, | ||
| _s_: a decimal String, | ||
| ): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"* | ||
| </h1> | ||
| <dl class="header"> | ||
| <dt>description</dt> | ||
| <dd>The returned String characterizes the plural category of _s_ according to _locale_, _type_, and _notation_.</dd> | ||
| <dd>The returned String characterizes the plural category of _s_ according to the effective locale and the internal slots of _pluralRules_: [[Type]], one of the String values *"cardinal"* or *"ordinal"*, [[Notation]], specifying the notation used, and [[CompactDisplay]], specifying whether compact notation affixes are to be displayed in short form or long form.</dd> | ||
| </dl> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are implementations allowed to use other slots of the Intl.PluralRules instance? A significant benefit of narrowly constraining parameters for implementation-defined abstract operations is that it makes clear what details must not affect their behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headers specify the slots of _pluralRules_ that are used. Is that sufficient to properly restrict slot usage, or is it necessary to restrict them via the parameters list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to do so via parameters, and if those ever get too excessive I'd advocate for introducing a new specialized record type (which here would be something like a Plural Rule Selector Record { [[Type]]: *"cardinal"* or *"ordinal"*, [[Notation]]: a string, [[CompactDisplay]]: *"short"* or *"long"* }).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed an update restoring the original parameters + the _compactDisplay_ parameter.
additionally: made the assignment to _pluralRules_.[[CompactDisplay]] in the PluralRules constructor non-conditional, since (correct me if I'm wrong) there's no reason not to just let it be *"short"* when using non-compact notations.
Co-authored-by: Richard Gibson <[email protected]>
…move conditional when setting _pluralRules_.[[CompactDisplay]]
3357fc0 to
c85b34b
Compare
gibson042
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
This is approved in TC39 september-22 meeting |
|
Please merge it asap |
|
This test need to be changed to include compactDisplay |
PR 1019 is approved by TG1 in 2025-9 meeting and should be merged soon. tc39/ecma402#1019
|
found an issue about this PR and report in #1031 |
To sync the implementation for the following 2 PRs tc39/ecma402#989 and tc39/ecma402#1019 PR 989, adding "notation", is already merged into ECMA402 in https://tc39.es/ecma402/#sec-intl.pluralrules https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select and https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions PR 1019 passed TC39 in 2025-Sept meeting and should be mereged into ECMA402 soon. Move some shared enum and code from anonymous namespace into Intl inside JSNumberFormat so code inside JSPluralRules can just reuse them. Also removed two function declaration inside Intl which no longer exist. Bug: 452130289 Change-Id: I47a68339802eaf8df31ccf99fd53a59c5c4f5370 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7047379 Commit-Queue: Frank Tang <[email protected]> Reviewed-by: Olivier Flückiger <[email protected]> Cr-Commit-Position: refs/heads/main@{#103187}
This PR allows implementations to take into account potential differences between the short compact form ("5K") and long form ("5 thousand") when determining the correct plural form to use.
Fixes: #1013