-
Notifications
You must be signed in to change notification settings - Fork 14
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
Make it possible to switch locales in a running sim #1302
Comments
Not done, but committed some progress (Molecule Shapes sim-specific is completely dynamic now, a lot of Gravity and Orbits is, but need to work on some details and some common interface). phetioValidation=false is needed for now, due to overrides file errors like:
I added the loadExtraLocales query parameter (for unbuilt sims, since they by default only load the NEEDED locales).
|
Added a VERY rough-draft locale switcher in the navbar for demo-ing, see https://bayes.colorado.edu/dev/olsonjb/locale-test.html |
That draft looks really amazing, nice work! |
Includes some layout/helper improvements that I'll port to master in the commits above. |
…zedString (with improved fallbacks), adding fallbackLocalesProperty/localeOrderProperty, see phetsims/chipper#1302
Branches deleted. |
Looking at the implementation and usages, I don't see how that's true, thoughts? |
I have a preference for all the exact locales first, then fallbacks (since |
@zepumph can you review the above and my commits? I believe I've handled or responded to everything. |
Can you please say a sentence about why we were using jsondiffpatch, even though we didn't end up going with that strategy?
Makes a lot of sense. I like the documentation! Thanks again for all this awesome work. What progress for PhET's codebase! Fee free to close. |
I don't think the remaining questions are blocking RC's for Gravity and Orbits, so I'll update this on the project board. |
In a case where we had a large JSON structure of "original string state" and "string state after", it was useful to diff the entire structure. Later once we had each LocalizedString with its individual knowledge, that wasn't necessary. |
…ching to --locales=*, supporting string Properties in Text/RichText constructors, adding jsondiffpatch for saving string state deltas in phet-io state see phetsims/chipper#1302
As @arouinfar mentioned in phetsims/joist#744 (comment), we would like the simulation to be able to switch languages from within the sim.
And in https://github.com/phetsims/studio/issues/192#issuecomment-730570376, where @kathy-phet also said:
This came up during https://github.com/phetsims/studio/issues/268 where @zepumph and I discovered that the locale query parameter wouldn't work out of the box because the text strings are phetioState: true and hence get overwritten by the state object. Uninstrumenting from state would make them non-customizable.
So I wanted to explore a path for changing the locale from within the sim, now that we have a vision for dynamic layout in phetsims/joist#608
I found that including all languages into the Gravity and Orbits all HTML file only increased the size from 2.8MB to 3.9MB or so, and I am not too worried about that additional size. I used this build command, but had to output a non-debug _all version by a change in chipper:
I experimented with an idea that getStringModule loads strings (for compatibility with existing code), but also loads a corresponding stringProperty (using a copy/paste preloadable TinyProperty). This means existing code will continue to work, but we can opt-in to a changeable string on a case-by-case basis. I tested this out with Gravity and Orbits, and was able to get several strings switching dynamically at runtime in both built and unbuilt mode.
Screen.Recording.2022-08-10.at.9.46.52.PM.mov
Here's the working copy experiment, which also changes the sim title.
Note there are several lint issues, type issues, etc in this experiment--just wanted to explore if this is where we want to be. Also, I created this issue here in chipper since that is where the strings are loaded and processed, even though this could have a Joist UI and overlap with a11y preferences and phet-io customizability.
Also heads up to @zepumph and @jessegreenberg and @pixelzoom about this idea.
UPDATE: Also heads up to @jbphet and @liam-mulhall since they work on rosetta.
The text was updated successfully, but these errors were encountered: