Skip to content

Commit 33893b3

Browse files
authored
Normative: Add [[CompactDisplay]] slot to Intl.PluralRules (#1019)
* Normative: Add [[CompactDisplay]] slot to Intl.PluralRules 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.
1 parent dd51408 commit 33893b3

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

spec/pluralrules.html

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h1>Intl.PluralRules ( [ _locales_ [ , _options_ ] ] )</h1>
1919

2020
<emu-alg>
2121
1. If NewTarget is *undefined*, throw a *TypeError* exception.
22-
1. Let _pluralRules_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.PluralRules.prototype%"*, « [[InitializedPluralRules]], [[Locale]], [[Type]], [[Notation]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]] »).
22+
1. Let _pluralRules_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.PluralRules.prototype%"*, « [[InitializedPluralRules]], [[Locale]], [[Type]], [[Notation]], [[CompactDisplay]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]] »).
2323
1. Let _optionsResolution_ be ? ResolveOptions(%Intl.PluralRules%, %Intl.PluralRules%.[[LocaleData]], _locales_, _options_, « ~coerce-options~ »).
2424
1. Set _options_ to _optionsResolution_.[[Options]].
2525
1. Let _r_ be _optionsResolution_.[[ResolvedLocale]].
@@ -28,6 +28,8 @@ <h1>Intl.PluralRules ( [ _locales_ [ , _options_ ] ] )</h1>
2828
1. Set _pluralRules_.[[Type]] to _t_.
2929
1. Let _notation_ be ? GetOption(_options_, *"notation"*, ~string~, « *"standard"*, *"scientific"*, *"engineering"*, *"compact"* », *"standard"*).
3030
1. Set _pluralRules_.[[Notation]] to _notation_.
31+
1. Let _compactDisplay_ be ? GetOption(_options_, *"compactDisplay"*, ~string~, « *"short"*, *"long"* », *"short"*).
32+
1. Set _pluralRules_.[[CompactDisplay]] to _compactDisplay_.
3133
1. Perform ? SetNumberFormatDigitOptions(_pluralRules_, _options_, 0, 3, _notation_).
3234
1. Return _pluralRules_.
3335
</emu-alg>
@@ -149,6 +151,11 @@ <h1>Intl.PluralRules.prototype.resolvedOptions ( )</h1>
149151
<td>*"notation"*</td>
150152
<td></td>
151153
</tr>
154+
<tr>
155+
<td>[[CompactDisplay]]</td>
156+
<td>*"compactDisplay"*</td>
157+
<td></td>
158+
</tr>
152159
<tr>
153160
<td>[[MinimumIntegerDigits]]</td>
154161
<td>*"minimumIntegerDigits"*</td>
@@ -252,6 +259,7 @@ <h1>Properties of Intl.PluralRules Instances</h1>
252259
<li>[[Locale]] is a String value with the language tag of the locale whose localization is used by the plural rules.</li>
253260
<li>[[Type]] is one of the String values *"cardinal"* or *"ordinal"*, identifying the plural rules used.</li>
254261
<li>[[Notation]] is one of the String values *"standard"*, *"scientific"*, *"engineering"*, or *"compact"*, identifying the notation used.</li>
262+
<li>[[CompactDisplay]] is one of the String values *"short"* or *"long"*, specifying whether to display compact notation affixes in short form ("5K") or long form ("5 thousand") if formatting with the *"compact"* notation, as this can in some cases influence plural form selection. It is only used when [[Notation]] has the value *"compact"*.</li>
255263
<li>[[MinimumIntegerDigits]] is a non-negative integer indicating the minimum integer digits to be used.</li>
256264
<li>[[MinimumFractionDigits]] and [[MaximumFractionDigits]] are non-negative integers indicating the minimum and maximum fraction digits to be used. Numbers will be rounded or padded with trailing zeroes if necessary.</li>
257265
<li>[[MinimumSignificantDigits]] and [[MaximumSignificantDigits]] are positive integers indicating the minimum and maximum fraction digits to be used. Either none or both of these properties are present; if they are, they override minimum and maximum integer and fraction digits.</li>
@@ -272,12 +280,13 @@ <h1>
272280
_locale_: a language tag,
273281
_type_: *"cardinal"* or *"ordinal"*,
274282
_notation_: a String,
283+
_compactDisplay_: *"short"* or *"long"*,
275284
_s_: a decimal String,
276285
): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*
277286
</h1>
278287
<dl class="header">
279288
<dt>description</dt>
280-
<dd>The returned String characterizes the plural category of _s_ according to _locale_, _type_, and _notation_.</dd>
289+
<dd>The returned String characterizes the plural category of _s_ according to _type_, _notation_, and _compactDisplay_ for the corresponding _locale_.</dd>
281290
</dl>
282291
</emu-clause>
283292

@@ -301,24 +310,26 @@ <h1>
301310
1. Let _locale_ be _pluralRules_.[[Locale]].
302311
1. Let _type_ be _pluralRules_.[[Type]].
303312
1. Let _notation_ be _pluralRules_.[[Notation]].
304-
1. Let _p_ be PluralRuleSelect(_locale_, _type_, _notation_, _s_).
313+
1. Let _compactDisplay_ be _pluralRules_.[[CompactDisplay]].
314+
1. Let _p_ be PluralRuleSelect(_locale_, _type_, _notation_, _compactDisplay_, _s_).
305315
1. Return the Record { [[PluralCategory]]: _p_, [[FormattedString]]: _s_ }.
306316
</emu-alg>
307317
</emu-clause>
308318

309319
<emu-clause id="sec-pluralruleselectrange" type="implementation-defined abstract operation">
310320
<h1>
311321
PluralRuleSelectRange (
312-
_locale_: a String,
322+
_locale_: a language tag,
313323
_type_: *"cardinal"* or *"ordinal"*,
314324
_notation_: a String,
325+
_compactDisplay_: *"short"* or *"long"*,
315326
_xp_: *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*,
316327
_yp_: *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*,
317328
): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*
318329
</h1>
319330
<dl class="header">
320331
<dt>description</dt>
321-
<dd>It performs an implementation-dependent algorithm to map the <emu-xref href="#sec-pluralruleselect">plural category</emu-xref> String values _xp_ and _yp_, respectively characterizing the start and end of a range, to a resolved String value for the plural form of the range as a whole denoted by _type_ and _notation_ for the corresponding _locale_, or the String value *"other"*.</dd>
332+
<dd>It performs an implementation-dependent algorithm to map the <emu-xref href="#sec-pluralruleselect">plural category</emu-xref> String values _xp_ and _yp_, respectively characterizing the start and end of a range, to a resolved String value for the plural form of the range as a whole denoted by _type_, _notation_, and _compactDisplay_ for the corresponding _locale_, or the String value *"other"*.</dd>
322333
</dl>
323334
</emu-clause>
324335

@@ -343,7 +354,8 @@ <h1>
343354
1. Let _locale_ be _pluralRules_.[[Locale]].
344355
1. Let _type_ be _pluralRules_.[[Type]].
345356
1. Let _notation_ be _pluralRules_.[[Notation]].
346-
1. Return PluralRuleSelectRange(_locale_, _type_, _notation_, _xp_.[[PluralCategory]], _yp_.[[PluralCategory]]).
357+
1. Let _compactDisplay_ be _pluralRules_.[[CompactDisplay]].
358+
1. Return PluralRuleSelectRange(_locale_, _type_, _notation_, _compactDisplay_, _xp_.[[PluralCategory]], _yp_.[[PluralCategory]]).
347359
</emu-alg>
348360
</emu-clause>
349361
</emu-clause>

0 commit comments

Comments
 (0)