Skip to content

Commit c7bca3a

Browse files
authored
Editorial: Inline the PluralRules GetOperands AO (#930)
GetOperands was only called from the ResolvePlural AO, which immediately passed the returned Record into the implementation-defined PluralRuleSelect AO. The revised version directly passes PluralRuleSelect the decimal String which was previously parsed by GetOperands. Implementations of PluralRuleSelect may (or may not) internally use something like GetOperands to determine the plural category returned. fixes #635
1 parent 0ae6386 commit c7bca3a

File tree

1 file changed

+6
-96
lines changed

1 file changed

+6
-96
lines changed

spec/pluralrules.html

Lines changed: 6 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -281,106 +281,17 @@ <h1>Properties of Intl.PluralRules Instances</h1>
281281
<emu-clause id="sec-intl-pluralrules-abstracts">
282282
<h1>Abstract Operations for PluralRules Objects</h1>
283283

284-
<emu-clause id="sec-getoperands" type="abstract operation">
285-
<h1>
286-
GetOperands (
287-
_s_: a decimal String,
288-
): a Plural Rules Operands Record
289-
</h1>
290-
<dl class="header">
291-
<dt>description</dt>
292-
<dd>It extracts numeric features from _s_ that correspond with the operands of <a href="https://unicode.org/reports/tr35/tr35-numbers.html#Operands">Unicode Technical Standard #35 Part 3 Numbers, Section 5.1.1 Operands</a>.</dd>
293-
</dl>
294-
<emu-alg>
295-
1. Let _n_ be ! ToNumber(_s_).
296-
1. Assert: _n_ is finite.
297-
1. Let _dp_ be StringIndexOf(_s_, *"."*, 0).
298-
1. If _dp_ is ~not-found~, then
299-
1. Let _intPart_ be _n_.
300-
1. Let _fracSlice_ be *""*.
301-
1. Else,
302-
1. Let _intPart_ be the substring of _s_ from 0 to _dp_.
303-
1. Let _fracSlice_ be the substring of _s_ from _dp_ + 1.
304-
1. Let _i_ be abs(! ToNumber(_intPart_)).
305-
1. Let _fracDigitCount_ be the length of _fracSlice_.
306-
1. Let _f_ be ! ToNumber(_fracSlice_).
307-
1. Let _significantFracSlice_ be the value of _fracSlice_ stripped of trailing *"0"*.
308-
1. Let _significantFracDigitCount_ be the length of _significantFracSlice_.
309-
1. Let _significantFrac_ be ! ToNumber(_significantFracSlice_).
310-
1. Return a new Plural Rules Operands Record { [[Number]]: abs(_n_), [[IntegerDigits]]: _i_, [[FractionDigits]]: _f_, [[NumberOfFractionDigits]]: _fracDigitCount_, [[FractionDigitsWithoutTrailing]]: _significantFrac_, [[NumberOfFractionDigitsWithoutTrailing]]: _significantFracDigitCount_ }.
311-
</emu-alg>
312-
</emu-clause>
313-
314-
<emu-clause id="sec-plural-rules-operands-records">
315-
<h1>Plural Rules Operands Records</h1>
316-
317-
<p>
318-
Each <dfn id="plural-operands-record">Plural Rules Operands Record</dfn> has the fields defined in <emu-xref href="#table-plural-operands"></emu-xref>.
319-
</p>
320-
321-
<emu-table id="table-plural-operands">
322-
<emu-caption>Plural Rules Operands Record Fields</emu-caption>
323-
<table class="real-table">
324-
<thead>
325-
<tr>
326-
<th>Field Name</th>
327-
<th>Value Type</th>
328-
<th>UTS #35 Operand</th>
329-
<th>Description</th>
330-
</tr>
331-
</thead>
332-
<tr>
333-
<td>[[Number]]</td>
334-
<td>Number</td>
335-
<td>n</td>
336-
<td>Absolute value of the source number</td>
337-
</tr>
338-
<tr>
339-
<td>[[IntegerDigits]]</td>
340-
<td>Number</td>
341-
<td>i</td>
342-
<td>Integer part of [[Number]].</td>
343-
</tr>
344-
<tr>
345-
<td>[[FractionDigits]]</td>
346-
<td>Number</td>
347-
<td>f</td>
348-
<td>Visible fraction digits in [[Number]], <em>with</em> trailing zeroes, as an integer having [[NumberOfFractionDigits]] digits.</td>
349-
</tr>
350-
<tr>
351-
<td>[[NumberOfFractionDigits]]</td>
352-
<td>Number</td>
353-
<td>v</td>
354-
<td>Number of visible fraction digits in [[Number]], <em>with</em> trailing zeroes.</td>
355-
</tr>
356-
<tr>
357-
<td>[[FractionDigitsWithoutTrailing]]</td>
358-
<td>Number</td>
359-
<td>t</td>
360-
<td>Visible fraction digits in [[Number]], <em>without</em> trailing zeroes, as an integer having [[NumberOfFractionDigitsWithoutTrailing]] digits.</td>
361-
</tr>
362-
<tr>
363-
<td>[[NumberOfFractionDigitsWithoutTrailing]]</td>
364-
<td>Number</td>
365-
<td>w</td>
366-
<td>Number of visible fraction digits in [[Number]], <em>without</em> trailing zeroes.</td>
367-
</tr>
368-
</table>
369-
</emu-table>
370-
</emu-clause>
371-
372284
<emu-clause id="sec-pluralruleselect" type="implementation-defined abstract operation">
373285
<h1>
374286
PluralRuleSelect (
375-
_locale_: a String,
287+
_locale_: a language tag,
376288
_type_: *"cardinal"* or *"ordinal"*,
377-
_n_: a finite Number,
378-
_operands_: a Plural Rules Operands Record derived from formatting _n_,
289+
_s_: a decimal String,
379290
): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"*
380291
</h1>
381292
<dl class="header">
382293
<dt>description</dt>
383-
<dd>The returned String best categorizes the _operands_ representation of _n_ according to the rules for _locale_ and _type_.</dd>
294+
<dd>The returned String characterizes the plural category of _s_ according to the effective locale and the options of _pluralRules_.</dd>
384295
</dl>
385296
</emu-clause>
386297

@@ -399,12 +310,11 @@ <h1>
399310
1. If _n_ is not a finite Number, then
400311
1. Let _s_ be ! ToString(_n_).
401312
1. Return the Record { [[PluralCategory]]: *"other"*, [[FormattedString]]: _s_ }.
402-
1. Let _locale_ be _pluralRules_.[[Locale]].
403-
1. Let _type_ be _pluralRules_.[[Type]].
404313
1. Let _res_ be FormatNumericToString(_pluralRules_, ℝ(_n_)).
405314
1. Let _s_ be _res_.[[FormattedString]].
406-
1. Let _operands_ be GetOperands(_s_).
407-
1. Let _p_ be PluralRuleSelect(_locale_, _type_, _n_, _operands_).
315+
1. Let _locale_ be _pluralRules_.[[Locale]].
316+
1. Let _type_ be _pluralRules_.[[Type]].
317+
1. Let _p_ be PluralRuleSelect(_locale_, _type_, _s_).
408318
1. Return the Record { [[PluralCategory]]: _p_, [[FormattedString]]: _s_ }.
409319
</emu-alg>
410320
</emu-clause>

0 commit comments

Comments
 (0)