Intl.js icon indicating copy to clipboard operation
Intl.js copied to clipboard

Import plural rules data

Open zbraniecki opened this issue 9 years ago • 10 comments

I'm working on adding Intl.PluralRules to Intl.js[0].

One area which I could use help with is getting the data for the API available.

The data should be pulled from CLDR json/xml, parsed into JS functions and attached so that [1] can read it.

It seems to me that the easiest way to achieve it would be to reuse @eemeli's make-plural.js[2]. @eemeli, would you be able to help me get it hooked into Intl.js?

[0] https://github.com/zbraniecki/Intl.js/tree/pluralrules [1] https://github.com/zbraniecki/Intl.js/blob/pluralrules/src/core.js#L92 [2] https://github.com/eemeli/make-plural.js

zbraniecki avatar Oct 13 '16 17:10 zbraniecki

Sure. Actually, for something of a lark and as a proof-of-concept, I put together an Intl.PluralRules polyfill a year ago, based on the then-current version of the draft & also using make-plural.js. I'll have a look at the state of this codebase, and see what's needed. No promises on timeframes, though.

eemeli avatar Oct 13 '16 18:10 eemeli

I can probably help with this.

caridy avatar Oct 13 '16 18:10 caridy

@caridy - awesome!

@eemeli - yeah, it's actually awesome to work with multiple different polyfills while ironing out the spec. I have your polyfill, my polyfill, my Gecko implementation and now I'm trying to write the Intl.js patch without looking at other polyfills - just following the spec ;)

zbraniecki avatar Oct 13 '16 19:10 zbraniecki

I'll have a go at writing a PluralRuleSelection function that uses make-plural.js for its "implementation dependent algorithm".

eemeli avatar Oct 13 '16 19:10 eemeli

@eemeli awesome! Thank you.

Please, make sure to stay in line with @caridy's planned https://github.com/andyearnshaw/Intl.js/issues/242 - I want to make sure that PluralRules is an optional plugin for Intl.js.

zbraniecki avatar Oct 13 '16 19:10 zbraniecki

You should probably have a look at what the formatJS guys did in their library. They have ICU message formatting and plural rules. And everything based on CLDR data, too.

swernerx avatar Nov 29 '16 17:11 swernerx

@caridy , @eemeli - can you guys help me get PluralRules into Intl.js? I landed it in SpiderMonkey, and would like to get a separate implementation to test the spec fully.

zbraniecki avatar Dec 21 '16 06:12 zbraniecki

Ummm. Did you perhaps miss my PR for this, onto your zbraniecki:pluralrules branch?

https://github.com/zbraniecki/Intl.js/pull/1

eemeli avatar Dec 21 '16 10:12 eemeli

Is this still an issue?

caridy avatar Jan 16 '17 17:01 caridy

The plurals are imported, but I can't get to test it, details in #1.

zbraniecki avatar Jan 16 '17 20:01 zbraniecki