Skip to content

Commit 749a502

Browse files
aphillipseemeli
andauthored
Clarify rule selection (#878)
* Clarify rule selection Fixes #868 This adds normative SHOULD language to using CLDR plural and ordinal data, which was intended originally. - clarifies that keyword selection follows exact match - clarifies the purpose of rule-based selection - makes non-CLDR-based implementation permitted * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> --------- Co-authored-by: Eemeli Aro <[email protected]>
1 parent 058a6d6 commit 749a502

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

spec/registry.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ When provided as a string, the representation of a digit size option matches the
393393
Number selection has three modes:
394394
- `exact` selection matches the operand to explicit numeric keys exactly
395395
- `plural` selection matches the operand to explicit numeric keys exactly
396-
or to plural rule categories if there is no explicit match
396+
followed by a plural rule category if there is no explicit match
397397
- `ordinal` selection matches the operand to explicit numeric keys exactly
398-
or to ordinal rule categories if there is no explicit match
398+
followed by an ordinal rule category if there is no explicit match
399399
400400
When implementing [`MatchSelectorKeys(resolvedSelector, keys)`](/spec/formatting.md#resolve-preferences)
401401
where `resolvedSelector` is the resolved value of a _selector_ _expression_
@@ -423,25 +423,39 @@ numeric selectors perform as described below.
423423
424424
#### Rule Selection
425425
426-
If the option `select` is set to `exact`, rule-based selection is not used.
427-
Return the empty string.
426+
Rule selection is intended to support the grammatical matching needs of different
427+
languages/locales in order to support plural or ordinal numeric values.
428+
429+
If the _option_ `select` is set to `exact`, rule-based selection is not used.
430+
Otherwise rule selection matches the _operand_, as modified by function _options_, to exactly one of these keywords:
431+
`zero`, `one`, `two`, `few`, `many`, or `other`.
432+
The keyword `other` is the default.
428433
429434
> [!NOTE]
430435
> Since valid keys cannot be the empty string in a numeric expression, returning the
431436
> empty string disables keyword selection.
432437
433-
If the option `select` is set to `plural`, selection should be based on CLDR plural rule data
434-
of type `cardinal`. See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
435-
for examples.
438+
The meaning of the keywords is locale-dependent and implementation-defined.
439+
A _key_ that matches the rule-selected keyword is a stronger match than the fallback key `*`
440+
but a weaker match than any exact match _key_ value.
436441
437-
If the option `select` is set to `ordinal`, selection should be based on CLDR plural rule data
438-
of type `ordinal`. See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
439-
for examples.
442+
The rules for a given locale might not produce all of the keywords.
443+
A given _operand_ value might produce different keywords depending on the locale.
440444
441-
Apply the rules defined by CLDR to the resolved value of the operand and the function options,
445+
Apply the rules to the resolved value of the _operand_ and the relevant function _options_,
442446
and return the resulting keyword.
443447
If no rules match, return `other`.
444448
449+
If the option `select` is set to `plural`, the rules applied to selection SHOULD be
450+
the CLDR plural rule data of type `cardinal`.
451+
See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
452+
for examples.
453+
454+
If the option `select` is set to `ordinal`, the rules applied to selection SHOULD be
455+
the CLDR plural rule data of type `ordinal`.
456+
See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
457+
for examples.
458+
445459
> **Example.**
446460
> In CLDR 44, the Czech (`cs`) plural rule set can be found
447461
> [here](https://www.unicode.org/cldr/charts/44/supplemental/language_plural_rules.html#cs).

0 commit comments

Comments
 (0)