Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Which part of Fluent is needed to parse?

29 views
Skip to first unread message

Ricardo Palomares Martínez

unread,
Dec 26, 2017, 5:15:58 AM12/26/17
to tools...@lists.mozilla.org
Hi,

This message is probably some days late or some days soon to be
answered, since Mozilla HQ is closed, but anyway... :-)

Since last time I checked the code, and IIUC, L20n JS implementation
code has moved to Fluent (if I'm wrong with this assumption, feel free
to dump the rest of my message and just tell me to keep looking to
L20n code). However, I remember that, despite not being a fluent (pun
intended!) JS reader, I had almost no difficulties to find a package
in L20n JS implementation aimed to get a full AST able to be used in a
localization tool. In my case, it was a candidate package to be ported
to Java.

However, I'm facing some more difficulties to find the equivalent for
Fluent. In the README.md of Fluent-JS:

https://github.com/projectfluent/fluent.js/blob/master/README.md

it is said that four packages exist and that they can be installed
independently. fluent-syntax is said to be a parser. However, the How
to use section is minimal and not illustrative, and the referenced
link (http://projectfluent.org/fluent.js/fluent-syntax) is basically a
mirror of the README.md, with another link
(http://projectfluent.io/fluent.js/fluent-syntax) leading to a 404.

Since L20n, or FTL now, is starting to land in desktop products, I'd
like to review the code to see if I would really be able to port it to
Java. So, what should I look to implement to get an AST parser?

TIA

--
Proyecto NAVE - http://www.proyectonave.es/
Mozilla Localization Project, es-ES Team
SeaMonkey Volunteer - https://www.seamonkey-project.org/

Axel Hecht

unread,
Dec 26, 2017, 7:27:31 AM12/26/17
to mozilla-t...@lists.mozilla.org
Am 26.12.17 um 11:15 schrieb Ricardo Palomares Martínez:
Hi Ricardo,

the js code you're looking for would be fluent-syntax, yeah. We use that
in pontoon for editing right now, so you can check
https://github.com/mozilla/pontoon/blob/master/pontoon/base/static/js/fluent_interface.js
for use-cases.

If you're porting parsers to a strictly typed language, maybe checking
the Rust implementation might be more useful,
https://github.com/projectfluent/fluent-rs, or the python version that
we're using in compare-locales and vcs sync on pontoon.

Note, we're going to wrap up version 0.5 of the syntax early next year,
which is going to shift some aspects of the grammar again. The master
branch of the rust impl has the most important ones, though. (section
comments and private messages)

Axel

Ricardo Palomares Martínez

unread,
Dec 26, 2017, 10:26:31 AM12/26/17
to mozilla-t...@lists.mozilla.org
El 26/12/17 a las 13:26, Axel Hecht escribió:
> Am 26.12.17 um 11:15 schrieb Ricardo Palomares Martínez:
>> Since L20n, or FTL now, is starting to land in desktop products, I'd
>> like to review the code to see if I would really be able to port it to
>> Java. So, what should I look to implement to get an AST parser?
>>
>
> Hi Ricardo,
>
> the js code you're looking for would be fluent-syntax, yeah. We use
> that in pontoon for editing right now, so you can check
> https://github.com/mozilla/pontoon/blob/master/pontoon/base/static/js/fluent_interface.js
> for use-cases.


Thank you for your quick answer. I'll check the code in Pontoon.


> If you're porting parsers to a strictly typed language, maybe checking
> the Rust implementation might be more useful,
> https://github.com/projectfluent/fluent-rs, or the python version that
> we're using in compare-locales and vcs sync on pontoon.


I find very difficult to follow Rust syntax, TBH. I remember last time
I found JS code very straightforward to convert it to Java
(presumably, also to C and C#). Dealing with types will be easy if the
code structures are similar; other than split classes in separate
files and adapt I/O procedures, I remember than most code in L20n AST
was almost ready to copy & paste to Java editor. I guess this will
happen with Fluent-syntax, too.


> Note, we're going to wrap up version 0.5 of the syntax early next
> year, which is going to shift some aspects of the grammar again. The
> master branch of the rust impl has the most important ones, though.
> (section comments and private messages)


OMG, that's not gonna end ever? :-) I remember more than 4 years ago,
when the first version of L20n came out and a guy had half done the
port to Java (https://github.com/antoineroux/l20n-java) and I was
happy to have found most work done. :'-(

I'll think I'll use a snapshot of current status in JS implementation.

Thanks again, and happy new year to everybody.

zbran...@mozilla.com

unread,
Jan 3, 2018, 2:44:25 PM1/3/18
to mozilla-t...@lists.mozilla.org
On Tuesday, December 26, 2017 at 7:26:31 AM UTC-8, Ricardo Palomares Martínez wrote:
> OMG, that's not gonna end ever? :-) I remember more than 4 years ago,
> when the first version of L20n came out and a guy had half done the
> port to Java (https://github.com/antoineroux/l20n-java) and I was
> happy to have found most work done. :'-(


Hahaha! Don't say that! :)

The scope of 0.5 changes are small enough to make us comfortable claiming that we're soft-freezing the syntax after 0.5 and toward 1.0.

There's currently really only one open issue which the Fluent owner (:stas) is considering and that's https://github.com/projectfluent/fluent/issues/63

As you can see it's rather minor syntactically and only impacts the UX of reading/writing the messages.

If all goes well, 0.5 is going to push us straight toward 1.0, so using its syntax is the recommended approach.

zb.
0 new messages