Intl Bindings

430 views
Skip to first unread message

Andy VanWagoner

unread,
Sep 30, 2016, 12:51:19 PM9/30/16
to elm-dev
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?

Andy VanWagoner

unread,
Sep 30, 2016, 3:03:52 PM9/30/16
to elm-dev
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?

Will

unread,
Oct 5, 2016, 8:05:31 AM10/5/16
to elm-dev
Would it help if all I want to do is format currency? GBP 1 -> £1.00
Message has been deleted

Andy VanWagoner

unread,
Oct 5, 2016, 10:14:24 AM10/5/16
to elm-dev
yup.

formatPounds =
  NumberFormat.fromOptions
    { locale = withDefault Locale.en (Locale.fromString "en-GB")
    , currency = Currency.gbp

Will

unread,
Oct 6, 2016, 8:09:00 AM10/6/16
to elm-dev
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.

Mateus CB

unread,
Nov 15, 2016, 12:32:08 PM11/15/16
to elm-dev
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.
Reply all
Reply to author
Forward
0 new messages