-
Notifications
You must be signed in to change notification settings - Fork 106
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
Intl.PluralRules() #34
Comments
Makes sense, and it aligns well with some other proposals around this. Last time we talked about ICU messages, we ended up agreeing that better to do baby steps on this and get pluralization in place instead. /cc @ericf, he has some ideas around this, and he was planning to champion the pluralization low level api. |
Here is a backpointer to the discussion: https://groups.google.com/forum/#!topic/javascript-globalization/3nFDf5al5hU |
@caridy Yeah @zbraniecki took this from the email thread. You guys both posted the same link to it :) |
jaja |
The latest proposal that seems to address all comments so far:
I would say that the latter method should be lower priority for us. I like how simple it is, but I'm not sure if it would really be applicable for libraries that need it, while the former is definitely going to be directly applicable in multiple libraries I know of. |
@zbraniecki let's keep the |
Ok guys, finally got a chance to work on this, the initial proposal flush out: https://github.com/caridy/intl-plural-form-spec The generated spec [draft] is here: I will work with @ericf next week for formalize the proposal and to see if we can formally presented (if we get a chance to add it to the agenda, which I doubt). P.S.: I hate to post in groups and here. |
Yes, just resolve plurals first… formatting is another step
Just post a link to here and say follow up in github? |
The spec looks great, very straightforward. |
/cc @eemeli |
Thanks for the pointer @rxaviers. I added my comments to the mailing list thread. Once the spec is ready-ish, I could probably pretty easily implement a polyfill for |
@eemeli awesome! I was hoping you'd say that 😄 |
@eemeli let's have the discussion about your feedback here tc39/proposal-intl-plural-rules#1 |
@eemeli thx |
update: we are cooking the proposal for the next meeting in two weeks. |
Forgot to mention it here, but I did actually end up writing a polyfill for Intl.PluralRules. There are some comments about how it diverges from the current spec at tc39/proposal-intl-plural-rules#3 |
we have reached stage 1 on this proposal :) |
🎉 |
Heads up, this has been advanced to Stage 2 as of today. @ericf is championing it and what's left is to update the spec to deal with decimal portion of the Number. We have reviewers assigned. |
A few feature requests came up in discussion among some of us working on ECMA-402. I'm not sure if they might already be reflected in the text, but just to record the discussion, here's what we've talked about:
var pr = new Intl.PluralRules('en', { type: 'cardinal' })
switch (pr.select(beers)) {
case 'one': return 'one beer';
default: return `${beers} beers`;
} |
Great! However, the current draft still has the issue of not dealing correctly with the categorisation of numerical strings with visible fractional digits that end in For a specific example, in English you have To fix this, ResolvePlural should accept string input that it asserts to contain the string representation of a number, and the Or is this what you meant by the "decimal portion of the Number"? |
that is correct @eemeli, that's what @littledan meant by "decimal portion of the Number", we have some ideas about how to solve that in the spec text, we will be working on that very soon. |
I also added tc39/proposal-intl-plural-rules#5, which drops the forced cast to Number that would make @zbraniecki's |
This proposal has been submitted to reviewers and we hope to be able to advance to Stage 3 at TC39 meeting in Munich in May. |
This proposal has been advanced to Stage 3. There's still editorial work going on in tc39/proposal-intl-plural-rules#15 , but the API is ready and I started working on SpiderMonkey implementation (behind the flag). I think we may want to start working on Intl.js one and test262 tests soon. |
@eemeli - I started working on an implementation of the spec for Intl.js. One item that I could use help with is getting the data from CLDR into the lib. Did you solve it already and can you port it to Intl.js? |
In make-plural.js I use Unicode's own cldr-core JSON export of the official XML data. Is that what you're looking for? |
Opened an issue in andyearnshaw/Intl.js#243 |
I landed @jungshik, @littledan - is there a chance we could get it in V8 anytime soon? |
We have a bug open for it, but we don't have an implementation yet. I'd like to avoid thinking about these things as a race against time. It doesn't seem likely that this will get into ES2017, but the annual version numbers shouldn't matter for most purposes. Instead, what should matter is when it gets to Stage 4, meeting by meeting, so there's no real significant cutoff cliff. Chrome has shipped a number of features when they were at Stage 4 without waiting for the annual numbered version, e.g., async/await. I've been making some changes to the Intl implementation recently to try to make our ECMA 402 implementation have less technical debt so it easier to add more features. We have this bug filed. Many people are taking Christmas break. Let's be OK with this taking a little bit of time. |
As I mentioned in the other comment, my understanding was that ES releases are creating opportunity to increase adoption of ECMA402 features.
Understood. |
Any reason |
@ray007 Can you say more about your use case? |
Our customers can configure "number controls" which allows to select 1 of several styles. |
@ray007 are you saying |
Explain? |
Sorry, but your suggestion is pretty vague to me and you're not helping to clarify it. |
To use your example:
should return Guess that means, |
Thanks, I know understand what you want. Though, I'm afraid such feature isn't the right way to go. Please, see this reply from Mark Davis (Unicode president) about this topic: http://unicode.org/pipermail/cldr-users/2016-February/000462.html |
ordinal number formatting has nothing to do with PluralRules. |
This proposal has advanced to Stage 4 at today's TC39 meeting. The committee raised a question about rationale for Using Fluent syntax:
vs.
But we identified a number of languages that require a whole sentence to be adjusted based on the ordinal plural category. Examples:
For example in Filipino it seems to require:
while Irish requires:
Thus we decided to stay with the current proposal and advance it to Stage 4! |
@littledan are you going to send the PR to merge the new spec into 402? or do you need some help? |
|
V8 v6.3.172 and Chrome 63 ship it as well. https://developers.google.com/web/updates/2017/10/intl-pluralrules |
Joining the party a bit late here, but the PR to add PluralRules to ChakraCore has opened and should land soon (coming in Edge later this year): chakra-core/ChakraCore#4940 |
As a sidenote, I recently updated my polyfill to match the current spec: https://github.com/eemeli/intl-pluralrules |
UPDATE: This proposal has advanced to stage 1, details here: https://github.com/caridy/intl-plural-rules-spec
cloned from: https://groups.google.com/forum/#!topic/javascript-globalization/3nFDf5al5hU
It would be very helpful for all l10n libraries to get CLDR plural forms into Intl API.
The proposed API could look like this:
The text was updated successfully, but these errors were encountered: