phetsims / gravity-and-orbits

"Gravity And Orbits" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
12 stars 6 forks source link

Migrate prior customized strings to new localized strings #469

Closed samreid closed 1 year ago

samreid commented 2 years ago

Migrate prior customized strings to new localized strings

samreid commented 2 years ago

There are no stringProperty in 1.5, and here are all the textProperty:

```json [ "gravityAndOrbits.general.view.navigationBar.titleText.textProperty", "gravityAndOrbits.general.view.navigationBar.phetButton.phetMenu.aboutDialogCapsule.archetype.termsPrivacyAndLicensingLinkText.textProperty", "gravityAndOrbits.general.view.navigationBar.phetButton.phetMenu.aboutDialogCapsule.archetype.translationCreditsLinkText.textProperty", "gravityAndOrbits.general.view.navigationBar.phetButton.phetMenu.aboutDialogCapsule.archetype.thirdPartyCreditsLinkText.textProperty", "gravityAndOrbits.general.view.navigationBar.phetButton.phetMenu.optionsDialogCapsule.archetype.title.textProperty", "gravityAndOrbits.general.view.navigationBar.modelScreenButton.text.textProperty", "gravityAndOrbits.general.view.navigationBar.toScaleScreenButton.text.textProperty", "gravityAndOrbits.homeScreen.view.titleText.textProperty", "gravityAndOrbits.homeScreen.view.buttonGroup.modelScreenButton.text.textProperty", "gravityAndOrbits.homeScreen.view.buttonGroup.toScaleScreenButton.text.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetSceneView.starNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetMoonSceneView.starNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetMoonSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetMoonSceneView.moonNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetMoonSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetMoonSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetMoonSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetMoonSceneView.moonNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetMoonSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetMoonSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetSatelliteSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetSatelliteSceneView.satelliteNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetSatelliteSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.playAreaNode.planetSatelliteSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.starPlanetSceneMassesControlPanel.starControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.starPlanetSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.starPlanetMoonSceneMassesControlPanel.starControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.starPlanetMoonSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.planetMoonSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.planetMoonSceneMassesControlPanel.moonControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.planetSatelliteSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.modelScreen.view.massesControlPanel.planetSatelliteSceneMassesControlPanel.satelliteControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetSceneView.starNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetMoonSceneView.starNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetMoonSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetMoonSceneView.moonNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetMoonSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.starPlanetMoonSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetMoonSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetMoonSceneView.moonNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetMoonSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetMoonSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetSatelliteSceneView.planetNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetSatelliteSceneView.satelliteNode.indicatorNode.labelNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetSatelliteSceneView.timeCounter.clearButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.playAreaNode.planetSatelliteSceneView.returnObjectsButton.textNode.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.starPlanetSceneMassesControlPanel.starControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.starPlanetSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.starPlanetMoonSceneMassesControlPanel.starControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.starPlanetMoonSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.planetMoonSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.planetMoonSceneMassesControlPanel.moonControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.planetSatelliteSceneMassesControlPanel.planetControlNode.massLabel.textProperty", "gravityAndOrbits.toScaleScreen.view.massesControlPanel.planetSatelliteSceneMassesControlPanel.satelliteControlNode.massLabel.textProperty" ] ```
samreid commented 2 years ago

I used this code in the console to set all textProperty to 'hello' in 1.5. You can see it is not very good coverage:

_.keys(phet.phetio.phetioEngine.phetioObjectMap).filter(k=>k.endsWith('textProperty')).forEach(phetioID => {phet.phetio.phetioEngine.phetioObjectMap[phetioID].value = 'hello';});
image
samreid commented 2 years ago

I thought it would work to add TandemFragmentRenamed rules, but somehow that state "hello" is not getting through:

new TandemFragmentRenamed( 'gravityAndOrbits.general.view.navigationBar.titleText.textProperty', 'gravityAndOrbits.general.view.navigationBar.titleText.stringProperty' ),
  new TandemFragmentRenamed( 'gravityAndOrbits.general.view.navigationBar.modelScreenButton.text.textProperty', 'gravityAndOrbits.general.model.strings.gravityAndOrbits.modelStringProperty' ),
  new TandemFragmentRenamed( 'gravityAndOrbits.modelScreen.view.playAreaNode.starPlanetSceneView.timeCounter.clearButton.textNode.textProperty', 'gravityAndOrbits.general.model.strings.gravityAndOrbits.clearStringProperty' )

@zepumph do we need a different kind of migration rule for things like this? Or is something broken about TandemFragmentRenamed? Or am I confused or using it wrong?

zepumph commented 2 years ago

@samreid and I discussed and we found 2 problems:

  1. You can't put these rules at the bottom of the migration rules, because if after this rule then it won't work: https://github.com/phetsims/phet-io-sim-specific/blob/c64deb3aba0bce890662a2799b70b6c50b957af2/repos/gravity-and-orbits/js/gravity-and-orbits-migration-rules.ts#L34.
  2. This rule is wrong, it should point back to gravityAndOrbits.general.model.strings.gravityAndOrbits.gravityAndOrbits.titleStringProperty

From here we think @samreid should add rules for all featured text in 1.5, but not for ALL texts. Let's at least start there.

samreid commented 2 years ago

A better script:

_.keys(phet.phetio.phetioEngine.phetioObjectMap).filter(k=>k.endsWith('textProperty')).forEach(phetioID => {phet.phetio.phetioEngine.phetioObjectMap[phetioID].value = 'hello'+(count++);}); 
samreid commented 2 years ago

A problem as I go about this. In 1.5

gravityAndOrbits.${screen}.view.massesControlPanel.${sceneMassesControlPanel}.${body}ControlNode.massLabel.textProperty,

copy-pasted the value of "Sun" 4x times, one for each control. In 1.6, these are all coalesced. So using the script above, in 1.5, I see suns labeled hello27, hello29, hello52 and hello54, but in 1.6 they are all coalesced to hello54.

samreid commented 2 years ago

OK using the scripts above I was able to migrate forward all of the customizable strings from 1.5. Summarizing caveats from above:

Perhaps a review?

zepumph commented 1 year ago

Looks great thanks.

samreid commented 1 year ago

Tagging @arouinfar and @kathy-phet so they are aware of the "strings get coalesced" problem. In my opinion, it would be too complex to try to add heuristics to try to pick "the best" string to use. That mainly affects the body types in the play area and for the sliders (for this sim). Please open a separate issue if that requires further attention. Closing.