Skip to content

Commit a7ff535

Browse files
committed
Normative: add notation to PluralRules
Add a notation option to PluralRules constructor like NumberFormat and utilize it for resolving the plural category. Fixes: #399
1 parent 6caa3fb commit a7ff535

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
@@ -13,14 +13,16 @@ <h1>Intl.PluralRules ( [ _locales_ [ , _options_ ] ] )</h1>
1313

1414
<emu-alg>
1515
1. If NewTarget is *undefined*, throw a *TypeError* exception.
16-
1. Let _pluralRules_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.PluralRules.prototype%"*, « [[InitializedPluralRules]], [[Locale]], [[Type]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]] »).
16+
1. Let _pluralRules_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.PluralRules.prototype%"*, « [[InitializedPluralRules]], [[Locale]], [[Type]], [[Notation]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]] »).
1717
1. Let _optionsResolution_ be ? ResolveOptions(%Intl.PluralRules%, %Intl.PluralRules%.[[LocaleData]], _locales_, _options_, « ~coerce-options~ »).
1818
1. Set _options_ to _optionsResolution_.[[Options]].
1919
1. Let _r_ be _optionsResolution_.[[ResolvedLocale]].
2020
1. Set _pluralRules_.[[Locale]] to _r_.[[Locale]].
2121
1. Let _t_ be ? GetOption(_options_, *"type"*, ~string~, « *"cardinal"*, *"ordinal"* », *"cardinal"*).
2222
1. Set _pluralRules_.[[Type]] to _t_.
23-
1. Perform ? SetNumberFormatDigitOptions(_pluralRules_, _options_, 0, 3, *"standard"*).
23+
1. Let _notation_ be ? GetOption(_options_, *"notation"*, ~string~, « *"standard"*, *"scientific"*, *"engineering"*, *"compact"* », *"standard"*).
24+
1. Set _pluralRules_.[[Notation]] to _notation_.
25+
1. Perform ? SetNumberFormatDigitOptions(_pluralRules_, _options_, 0, 3, _notation_).
2426
1. Return _pluralRules_.
2527
</emu-alg>
2628
</emu-clause>
@@ -126,6 +128,11 @@ <h1>Intl.PluralRules.prototype.resolvedOptions ( )</h1>
126128
<td>*"type"*</td>
127129
<td></td>
128130
</tr>
131+
<tr>
132+
<td>[[Notation]]</td>
133+
<td>*"notation"*</td>
134+
<td></td>
135+
</tr>
129136
<tr>
130137
<td>[[MinimumIntegerDigits]]</td>
131138
<td>*"minimumIntegerDigits"*</td>
@@ -228,6 +235,7 @@ <h1>Properties of Intl.PluralRules Instances</h1>
228235
<ul>
229236
<li>[[Locale]] is a String value with the language tag of the locale whose localization is used by the plural rules.</li>
230237
<li>[[Type]] is one of the String values *"cardinal"* or *"ordinal"*, identifying the plural rules used.</li>
238+
<li>[[Notation]] is one of the String values *"standard"*, *"scientific"*, *"engineering"*, or *"compact"*, identifying the notation used.</li>
231239
<li>[[MinimumIntegerDigits]] is a non-negative integer indicating the minimum integer digits to be used.</li>
232240
<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>
233241
<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>
@@ -247,12 +255,13 @@ <h1>
247255
PluralRuleSelect (
248256
_locale_: a language tag,
249257
_type_: *"cardinal"* or *"ordinal"*,
258+
_notation_: a String,
250259
_s_: a decimal String,
251260
): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*
252261
</h1>
253262
<dl class="header">
254263
<dt>description</dt>
255-
<dd>The returned String characterizes the plural category of _s_ according to the effective locale and the options of _pluralRules_.</dd>
264+
<dd>The returned String characterizes the plural category of _s_ according to _locale_, _type_ and _notation_.</dd>
256265
</dl>
257266
</emu-clause>
258267

@@ -275,7 +284,8 @@ <h1>
275284
1. Let _s_ be _res_.[[FormattedString]].
276285
1. Let _locale_ be _pluralRules_.[[Locale]].
277286
1. Let _type_ be _pluralRules_.[[Type]].
278-
1. Let _p_ be PluralRuleSelect(_locale_, _type_, _s_).
287+
1. Let _notation_ be _pluralRules_.[[Notation]].
288+
1. Let _p_ be PluralRuleSelect(_locale_, _type_, _notation_, _s_).
279289
1. Return the Record { [[PluralCategory]]: _p_, [[FormattedString]]: _s_ }.
280290
</emu-alg>
281291
</emu-clause>
@@ -285,13 +295,14 @@ <h1>
285295
PluralRuleSelectRange (
286296
_locale_: a String,
287297
_type_: *"cardinal"* or *"ordinal"*,
298+
_notation_: a String,
288299
_xp_: *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*,
289300
_yp_: *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*,
290301
): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*
291302
</h1>
292303
<dl class="header">
293304
<dt>description</dt>
294-
<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_ for the corresponding _locale_, or the String value *"other"*.</dd>
305+
<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>
295306
</dl>
296307
</emu-clause>
297308

@@ -315,7 +326,8 @@ <h1>
315326
1. Return _xp_.[[PluralCategory]].
316327
1. Let _locale_ be _pluralRules_.[[Locale]].
317328
1. Let _type_ be _pluralRules_.[[Type]].
318-
1. Return PluralRuleSelectRange(_locale_, _type_, _xp_.[[PluralCategory]], _yp_.[[PluralCategory]]).
329+
1. Let _notation_ be _pluralRules_.[[Notation]].
330+
1. Return PluralRuleSelectRange(_locale_, _type_, _notation_, _xp_.[[PluralCategory]], _yp_.[[PluralCategory]]).
319331
</emu-alg>
320332
</emu-clause>
321333
</emu-clause>

0 commit comments

Comments
 (0)