Skip to content

Conversation

ben-allen
Copy link
Contributor

@ben-allen ben-allen commented Aug 8, 2025

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

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.
@ben-allen ben-allen requested a review from ryzokuken August 8, 2025 16:36
@ben-allen
Copy link
Contributor Author

note: the potentially controversial decision here is to have PluralRuleSelect and PluralRuleSelectRange take an Intl.PluralRules object, in order to avoid having it take an additional very rarely used compactDisplay parameter.

Comment on lines 280 to 288
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>
Copy link
Contributor

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.

Copy link
Contributor Author

@ben-allen ben-allen Aug 12, 2025

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?

Copy link
Contributor

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"* }).

Copy link
Contributor Author

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.

ben-allen and others added 2 commits August 12, 2025 10:34
Co-authored-by: Richard Gibson <[email protected]>
…move conditional when setting _pluralRules_.[[CompactDisplay]]
@ben-allen ben-allen force-pushed the 1013-PluralRules-compactDisplay branch from 3357fc0 to c85b34b Compare August 12, 2025 19:10
Copy link
Contributor

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ben-allen ben-allen added has consensus Has consensus from TC39-TG2 needs consensus labels Aug 14, 2025
@sffc
Copy link
Contributor

sffc commented Aug 15, 2025

@sffc sffc moved this from Priority Issues to Previously Discussed in ECMA-402 Meeting Topics Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Previously Discussed
Development

Successfully merging this pull request may close these issues.

Add "compactDisplay" option to Intl.PluralRules
4 participants