phetsims / build-a-molecule

"Build a Molecule" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
8 stars 7 forks source link

i18n of molecule names #178

Closed jonathanolson closed 3 years ago

jonathanolson commented 4 years ago

Just want to check in and see if we were planning on allowing translation of molecule names at all (came up in https://github.com/phetsims/build-a-molecule/issues/173).

arouinfar commented 4 years ago

I think it would be nice to allow for i18n of the names of the 26 molecules in collectionMoleculesData.js. It would be overkill (and not particularly useful) to allow i18n of the names of the 9000+ molecules in otherMoleculesData.js.

Denz1994 commented 4 years ago

The 26 molecules in collectionMoleulesData.js are responsible for the molecules that show in the collection box. These strings are translatable as indicated by the stringTest query parameter. There are no further actions for this issue. Closing this issue.

jbphet commented 3 years ago

@DianaTavares contacted me via Slack and said that she was unable to translate the molecule names used in this sim into Spanish through the translation utility (aka Rosetta). I just logged into Rosetta and brought up the page for build-a-molecule and Spanish, and indeed, the molecule names from collectionMoleculesData.js are not available for translation. Above, @arouinfar recommended that they should be.

@Denz1994 - I think your test for translatability may have been flawed. I don't think testing that a string can be altered via stringTest proves that it is translatable. Can you investigate further? I think there may need to be some sort of mapping of the molecule names in collectionMoleculesData.js to strings in build-a-molecule-strings_en.json.

Also assigning @ariel-phet for prioritization.

ariel-phet commented 3 years ago

@Denz1994 this would probably be good to fix when we add in the new molecule data

oliver-phet commented 3 years ago

Just to add, please let me know when this has been added so that I can inform translators. I just got a report about this from Sandor.

jbphet commented 3 years ago

@Denz1994 and I discussed this today and he has a rough plan for how to make the molecules translatable. I offered to help with testing of the changes, since it will involve making changes to babel that we want to make sure don't get committed, at least not to the master branch.

Denz1994 commented 3 years ago

The strings that were previously used in the collection boxes were pulled from the CollectionMoleculesData.js and parsed for the molecule name. These didn't come from the string.json file. Some internal support was implemented so these "unofficial" strings could be changed under the testing conditions fired from the stringTest= query parameter.

The revision here was to add the entries for each file and then change CompleteMolecule.getDisplayName() to utilize the string from the .json file. If the molecule doesn't have an entry, it fallsback to using English (recovered from CollectionMoleculeData.js).

These entires were tested with the URL: http://localhost:8080/build-a-molecule/build-a-molecule_en.html?brand=phet&ea&easyMode&locale=es and a truncated build-a-molecule-strings_es.json file was built in babel (under the tests branch, not checked in).

This produced the below snapshot where the collection box, common name in dialog, and common name above the built molecule are all translated. Water, molecular oxygen, and molecular hydrogen were tested.

image

Denz1994 commented 3 years ago

Assigning to @jbphet for review. I believe this should have fixed the issue.

Denz1994 commented 3 years ago

While reviewing with @jbphet, we thought the implementation detailed above works as expected. These additional strings were tested against currently published "es" strings. @jbphet suggested doing a maintenance release and checking for these strings in the HTML of the built RC. Search for BUILD_A_MOLECULE/water for example.

Denz1994 commented 3 years ago

During the build process unused strings are stripped from the build artifact. When the strings are accessed via bracket notation (i.e. buildAMoleculeStrings[acetylene]), they don't get registered as accessed strings like when dot notation is used (i.e. buildAMoleculeStrings.acetylene).

We don't know what the strings are prior to loading the sim data so, we need to access them via a pseudo Strings object within CompleteMolecule.js. These additional strings are found in the HTML of the lastest RC build, so they can be translated once this version is pushed to production.

Denz1994 commented 3 years ago

Changes have been pushed. I'd suggest @DianaTavares try to translate one of the molecules in the collection boxes like "water" for example.

arouinfar commented 3 years ago

@Denz1994 two of the English strings are formatted like the string key, which is odd. image

Compare to other two-word molecule names: image

Unfortunately, this means that the molecule names of CO and CO2 appear incorrectly in the English sim. image

DianaTavares commented 3 years ago

the translations are working pretty well:

image

And now I have a long list of molecules names to translate in the translation tool, which I guess are all the molecules.

Denz1994 commented 3 years ago

Correct, the English entry didn't have a space for the two strings mentioned above. I'd just like an additional look at this change. In this version, the two strings have been fixed. Can you confirm @arouinfar?

https://phet-dev.colorado.edu/html/build-a-molecule/1.0.2-rc.1/phet/build-a-molecule_all_phet.html

ariel-phet commented 3 years ago

@Denz1994 I verified this fix

Denz1994 commented 3 years ago

Strings have been deployed here. Closing.