Skip to content

ICU underneath? #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tzutalin opened this issue Nov 11, 2018 · 2 comments
Closed

ICU underneath? #216

tzutalin opened this issue Nov 11, 2018 · 2 comments

Comments

@tzutalin
Copy link

tzutalin commented Nov 11, 2018

Hi,
Sorry, I didn't dive deeper beforehand. I have a quick question about the implementation of Fluent. How does Fluent do formatting? Do it use ICU formatting underneath, Fluent do the formatting on itself, or just use Intl formatting in JS? From my understanding, Intl is employing ICU.

@stasm
Copy link
Contributor

stasm commented Nov 13, 2018

Hi @tzutalin! The answer depends on the implementation. In JavaScript, I think most engines use ICU for formatting.

At its core, Fluent is a specification of a syntax used to store translations (the Fluent grammar) and the logic to format them such that they are ready to be used in the UI (the Fluent runtime). Right now we've mostly focused on the grammar part while the runtime part still needs more work to be well-specified. Once we get there, the specification will likely dictate that implementations format numbers and dates according to the rules of the given language (e.g. by using existing i18n solutions, like ICU).

Right now, we're focusing our efforts on three implementations listed below. I also know of a few more (C#, Elm) but I don't know what i18n solution they use.

  • JavaScript: fluent.js uses the Intl API specified by ECMA 402. I think that most browsers use ICU to implement it, although I'm not sure about Edge. @zbraniecki, can you confirm this, please?

  • Python: There's an open PR to python-fluent to add the runtime logic and it uses the Babel package to format numbers and dates. AFAICT, Babel doesn't use ICU under the hood.

  • Rust: fluent-rs doesn't currently format dates nor numbers at all. According to this issue, there weren't any i18n solutions available in the Rust ecosystem as of last year. I don't know if the situation has changed. We'll look into it early next year when fluent-rs hopefully becomes a priority for us.

Does this answer your question?

@tzutalin
Copy link
Author

tzutalin commented Nov 13, 2018

Thanks for your explanation. You did answer my question and I also check the resource code. fluent.js used Intl API(ICU impl) to do formatting. Have you planned to work on Java side? The tricky part for Java is to parse FTL's grammar and message and convert to ICU message which can be down in compiler or runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants