Intl Bindings

Affichage de 17 messages sur 7
Intl Bindings Andy VanWagoner 30/09/16 09:51
I tried to publish https://github.com/thetalecrafter/elm-intl but it contains Native modules, so I couldn't publish it myself. I think this policy totally makes sense.

The Internationalization API in JavaScript is certainly not something you would want to rewrite in Elm. The enormous CLDR data file required is more than you'd ever want to deliver to a front-end by itself, not counting the code to make use of it. Even the Intl.js polyfill doesn't include Intl.Collator because of the size constraints.

I would love for this API to be available in Elm without everybody needing to go through ports. What is the process for moving this forward?
Re: Intl Bindings Andy VanWagoner 30/09/16 12:03
As this is a platform API I thought it would make the most sense as a mostly-direct transform from JS to Elm. The basic functions of the underlying API (`compare` strings, `format` dates and numbers into strings) seemed to be a poor fit for async communication across a port. I'm open to suggestions on how Elm users would expect to create and use these formatters.

I'm surprised nobody had done this yet. How are others doing localization in Elm apps?
Re: Intl Bindings Will 05/10/16 05:05
Would it help if all I want to do is format currency? GBP 1 -> £1.00
unk...@googlegroups.com 05/10/16 07:12 <Ce message a été supprimé.>
Re: Intl Bindings Andy VanWagoner 05/10/16 07:14
yup.

formatPounds =
  NumberFormat.fromOptions
    { locale = withDefault Locale.en (Locale.fromString "en-GB")
    , currency = Currency.gbp
Re: Intl Bindings Will 06/10/16 05:09
Sorry, what I should have said is "Does it make sense to collect use-cases here?". Mine is currency formatting. I'm hoping that that would mean less work than porting all of Intl and its data to Elm.
Re: Intl Bindings Mateus CB 15/11/16 09:32
This would be a great addition to ELM. I'm currently working on a project that requires correct sorting of international strings (accents, logograms, etc..). The only way I'm aware to sort those correctly is by using the Collator.compare. Which this library has made that available in ELM. The currency and number formatting are also quite useful, although I'm currently not using it yet, our plan is to implement localized time/numbers.