Skip to content

Add ordinal plural example to guide #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2019
Merged

Conversation

eemeli
Copy link
Member

@eemeli eemeli commented Apr 22, 2019

As it's by no means obvious that NUMBER() may also be used to implement selectors on ordinal rather than cardinal plural categories, this PR adds a note about this to the syntax guide.

What's happening here is that the same options that are passed to Intl.NumberFormat are also passed to Intl.PluralRules, and NumberFormat ignores the type option. Admittedly there is a bit of a wtf stage that you go through if you start to think about this.

I'm not sure how JS-specific this functionality is.

@zbraniecki
Copy link
Collaborator

Maybe we should bring back explicit PLURAL for that? I'm concerned that NUMBER may be misleading.

@eemeli
Copy link
Member Author

eemeli commented Apr 22, 2019

I'd recommend keeping the current behaviour. Yes, it is admittedly a bit surprising, but it's not really misleading as such. It also conceptually matches the current special-casing of NUMBER() as a selector, as its options already influence the variant that's chosen. See for instance the minFractionDigits example immediately above my addition.

```
your-rank = { NUMBER($pos, type: "ordinal") ->
[1] You finished first!
[one] You finished {$pos}st
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of an explicit [1] variant combined with the generic [one]!

@stasm stasm merged commit 0588173 into projectfluent:master Apr 23, 2019
@eemeli eemeli deleted the ordinal branch September 27, 2019 10:01
Cimbali added a commit to Cimbali/python-fluent that referenced this pull request Oct 18, 2023
The type option is simply ignored outside of a select expression, and
allows to select based on CLDR plural categories for ordinals (which
differ from normal plurals aka cardinal numbers).

This is as per (part of) the docs, and per javascript implementation,
see projectfluent/fluent#259 -- I haven’t found any definition of
NUMBER() in the spec.
Cimbali added a commit to Cimbali/python-fluent that referenced this pull request Oct 18, 2023
The type option is simply ignored outside of a select expression, and
allows to select based on CLDR plural categories for ordinals (which
differ from normal plurals aka cardinal numbers).

This is as per (part of) the docs, and per javascript implementation,
see projectfluent/fluent#259 -- I haven’t found any definition of
NUMBER() in the spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants