phetsims / joist

Joist is the main framework for PhET Interactive Simulations. Joist creates and displays the simulation content, home screen, navigation bar, About dialog, enables switching between tabs, and other framework-related features.
http://scenerystack.org/
MIT License
9 stars 6 forks source link

Consider other file formats or libraries for strings to support accessibility i18n #990

Closed jessegreenberg closed 2 weeks ago

jessegreenberg commented 2 weeks ago

From #985 and #986.

We looked at format.js and fluent.js, which uses file formats with built in support for translation logic. While investigating we found Pontoon - a full stack translation solution. It lists a number of supported file formats and we want to learn more about them. We should also do another broad search for any others.

From Pontoon documentation:

Pontoon is a translation management system used and developed by the Mozilla localization community. It can handle any project that uses one of the supported file formats:

.dtd

.ftl (Fluent)

.inc

.ini

.json (WebExtensions)

.json (key-value)

.po (Gettext)

.properties

.xliff

.xml (Android)

jessegreenberg commented 2 weeks ago

Context for clarity

msgctxt "greeting" msgid "Welcome, user!" msgstr "¡Bienvenido, usuario!"

Plural form example

msgid "You have %d message." msgid_plural "You have %d messages." msgstr[0] "Tienes %d mensaje." msgstr[1] "Tienes %d mensajes."


- .properties - Usually used in Java apps. Has support for placeholders and comments, but no support for logic or pluralization. Not typical for we apps.
- .xliff - "XML Localization Interchange File Format". Designed to standardize the way translation data is structured. It is commonly used for translation in apps. It has good support for comments and metadata. It does not support logic. One might use xliff to store strings and then use fluent to handle the logic. Less used than JSON. Its benefits are mostly for standardization, cross-platform support, and metadata.
- .xml (android) - Specific to android, not relevant for web applications. The xml file holds strings, but there isn't set up to support logic.
jessegreenberg commented 2 weeks ago

Next, I searched for some other JavaScript tools for i18n. I found these:

jessegreenberg commented 2 weeks ago

From what I found in this issue, I think our decision is between Fluent and some library that supports ICU. Here are pros/cons for each:

I don't know if the features from Fluent will be needed by translators and if they are worth using when ICU appears to be a bit more standard.

jessegreenberg commented 2 weeks ago

@emily-phet @terracoda @jbphet and I just met to discuss the above notes.

We agreed that Fluent is the way to go. It has more features for complex translations than libraries backed by ICU, and we do not see any drawbacks. Fluent is also widely used, so we do not feel a need to use ICU just because it may be more standard.

@emily-phet found a good write up on Fluent vs ICU: https://github.com/projectfluent/fluent/wiki/Fluent-and-ICU-MessageFormat

Granted, the authors are biased towards Fluent, but it describes the differences well.

We are going to port accessibility strings to the Fluent format in a few sims, starting with ohms-law. Then we are going to get feedback from translators to determine how successful this is.