Hi! This is pretty good timing.
Fluent
A few months ago, I too started researching what a Fluent implementation in pure Elm could look like:
So far, I’ve written an FTL file parser and have begun work on a code generator that would make Elm modules for each translation file.
The plan is to generate functions that take all the arguments needed for a message and either return a String
or a more complex type depending on whether it contains markup. The idea is to provide hooks for markup to support not only elm/html
, but any other library like mdgriffith/elm-ui
.
Intl API
As mentioned in this thread, the most challenging part is not having synchronous access to the Intl API. Fluent requires this for plural rules, number formatting, date formatting, etc.
For that, I have started working on this:
The idea is to provide a pure Elm implementation of the Intl API, with Elm modules generated for each locale out of the CLDR.
As long as apps only reference the locales they use, Elm’s DCE (or LCI) should keep the generated JS small.
The downside is that you can’t load a locale dynamically unless you include them all. I’ve considered providing decoders instead of a codegen, but that would mean that Plural Rules would have to be “interpreted” at runtime, which could kill performance. Maybe there can be a mixed solution, though.
So far, I’ve written a Plural Rules parser and the most significant part of the Number Formatter.
–
Both projects are pretty ambitious, and I’m only working on them as a hobby. I haven’t done anything with dates yet, but I will have to eventually. I’d love to combine efforts if you’re interested!