Skip to content

Commit

Permalink
Clarify rule selection (#878)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
aphillips and eemeli authored Sep 9, 2024
1 parent 058a6d6 commit 749a502
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions spec/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ When provided as a string, the representation of a digit size option matches the
Number selection has three modes:
- `exact` selection matches the operand to explicit numeric keys exactly
- `plural` selection matches the operand to explicit numeric keys exactly
or to plural rule categories if there is no explicit match
followed by a plural rule category if there is no explicit match
- `ordinal` selection matches the operand to explicit numeric keys exactly
or to ordinal rule categories if there is no explicit match
followed by an ordinal rule category if there is no explicit match
When implementing [`MatchSelectorKeys(resolvedSelector, keys)`](/spec/formatting.md#resolve-preferences)
where `resolvedSelector` is the resolved value of a _selector_ _expression_
Expand Down Expand Up @@ -423,25 +423,39 @@ numeric selectors perform as described below.
#### Rule Selection
If the option `select` is set to `exact`, rule-based selection is not used.
Return the empty string.
Rule selection is intended to support the grammatical matching needs of different
languages/locales in order to support plural or ordinal numeric values.
If the _option_ `select` is set to `exact`, rule-based selection is not used.
Otherwise rule selection matches the _operand_, as modified by function _options_, to exactly one of these keywords:
`zero`, `one`, `two`, `few`, `many`, or `other`.
The keyword `other` is the default.
> [!NOTE]
> Since valid keys cannot be the empty string in a numeric expression, returning the
> empty string disables keyword selection.
If the option `select` is set to `plural`, selection should be based on CLDR plural rule data
of type `cardinal`. See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
for examples.
The meaning of the keywords is locale-dependent and implementation-defined.
A _key_ that matches the rule-selected keyword is a stronger match than the fallback key `*`
but a weaker match than any exact match _key_ value.
If the option `select` is set to `ordinal`, selection should be based on CLDR plural rule data
of type `ordinal`. See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
for examples.
The rules for a given locale might not produce all of the keywords.
A given _operand_ value might produce different keywords depending on the locale.
Apply the rules defined by CLDR to the resolved value of the operand and the function options,
Apply the rules to the resolved value of the _operand_ and the relevant function _options_,
and return the resulting keyword.
If no rules match, return `other`.
If the option `select` is set to `plural`, the rules applied to selection SHOULD be
the CLDR plural rule data of type `cardinal`.
See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
for examples.
If the option `select` is set to `ordinal`, the rules applied to selection SHOULD be
the CLDR plural rule data of type `ordinal`.
See [charts](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html)
for examples.
> **Example.**
> In CLDR 44, the Czech (`cs`) plural rule set can be found
> [here](https://www.unicode.org/cldr/charts/44/supplemental/language_plural_rules.html#cs).
Expand Down

0 comments on commit 749a502

Please sign in to comment.