Skip to content
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

Find a better way to get translated screen names for the website #1367

Closed
jonathanolson opened this issue Dec 14, 2022 · 11 comments
Closed

Find a better way to get translated screen names for the website #1367

jonathanolson opened this issue Dec 14, 2022 · 11 comments

Comments

@jonathanolson
Copy link
Contributor

It sounds like it's taking 7 minutes to parse out the screen names right now (but running the simulation for every locale). This seems inefficient, perhaps we can generate these during the simulation build quickly (especially if sims report out what their string keys are for the screens).

@jonathanolson jonathanolson self-assigned this Dec 14, 2022
@mattpen
Copy link
Contributor

mattpen commented Dec 16, 2022

especially if sims report out what their string keys are for the screens

Even if this is all we could provide to the build-server, it would be pretty simple to fetch these from babel - much more efficient than running puppeteer to scrape the screen names from joist at runtime.


Also, if this proves difficult, one other option is for the website to do this asyncrounously whenever it generates the other file related content for the metadata (currently scheduled once/day). This would accomplish the goal of speeding the builds up anyway.

@jonathanolson
Copy link
Contributor Author

This would allow us to NOT run puppeteer to grab the screen names out of sims, AND would be fairly feasible to patch for older simulations AND master. THIS would allow us to remove puppeteer usage from build-server, which would make it much more robust and faster (although phet-io brand builds will still run puppeteer).

This would knock off at least 8 hours from a full production deployment of all release branches.

I'll need to talk to other devs about this, but here's my proposal:

We include an array of screen name string keys in the package.json, e.g. in area-model-algebra's package.json:

    "screenNameKeys": [
      "AREA_MODEL_COMMON/screen.explore",
      "AREA_MODEL_COMMON/screen.generic",
      "AREA_MODEL_COMMON/screen.variables",
      "AREA_MODEL_COMMON/screen.game"
    ]

This would only be done for multi-screen sims (would not exist for single-screen sims).

This can be generated for most older sims by running puppeteer and filtering keys with something like:

const likelyKeys = Object.keys( phet.chipper.strings.en ).filter( str => str.includes( 'creen' ) && !str.includes( 'JOIST' ) && !str.includes( 'SCENERY_PHET' ) );
_.find( likelyKeys, key => phet.chipper.strings.en[ key ] === phet.joist.sim.screens[ 1 ].nameProperty.value )

Additionally, on master, we can add code to make sure this doesn't get out-of-sync. It's possible to tag the stringProperties with a stringKey field (with minor modifications to getStringModule and LocalizedString), and then we can add assertions to make sure they match up.

@jonathanolson
Copy link
Contributor Author

I'll also add assertions in Screen to make sure that the key provided is in the package.json, so it doesn't get out-of-sync.

jonathanolson added a commit to phetsims/perennial that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/keplers-laws that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/mobius that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/molecule-shapes-basics that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/number-compare that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/make-a-ten that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/projectile-motion that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/number-line-integers that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/molecule-polarity that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/ratio-and-proportion that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/rutherford-scattering that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/reactants-products-and-leftovers that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/plinko-probability that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/simula-rasa that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/states-of-matter that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/proportion-playground that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/pendulum-lab that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/ph-scale-basics that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/ph-scale-basics that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/plinko-probability that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/projectile-motion that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/proportion-playground that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/ratio-and-proportion that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/reactants-products-and-leftovers that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/resistance-in-a-wire that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/resistance-in-a-wire that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/rutherford-scattering that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/states-of-matter that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/states-of-matter-basics that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/trig-tour that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/under-pressure that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/unit-rates that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/vector-addition that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/vector-addition-equations that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/wave-interference that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/wave-on-a-string that referenced this issue May 10, 2023
jonathanolson added a commit to phetsims/waves-intro that referenced this issue May 10, 2023
@jonathanolson
Copy link
Contributor Author

Production links, I'll test:

acid-base-solutions 1.2 ()

area-builder 1.1 ()

area-model-algebra 1.2 ()

area-model-decimals 1.2 ()

area-model-introduction 1.2 ()

area-model-multiplication 1.2 ()

arithmetic 1.0 ()

atomic-interactions 1.2 ()

balancing-act 1.1 ()

balancing-chemical-equations 1.2 ()

balloons-and-static-electricity 1.3-phetio ()

balloons-and-static-electricity 1.5 ()

beers-law-lab 1.7 ()

bending-light 1.1 ()

blackbody-spectrum 1.0 ()

build-a-fraction 1.0 ()

build-a-molecule 1.0 ()

build-a-nucleus 1.0 ()

build-an-atom 1.5-phetio ()

build-an-atom 1.6 ()

calculus-grapher 1.0 ()

capacitor-lab-basics 1.6 ()

center-and-variability 1.0 ()

charges-and-fields 1.0 ()

charges-and-fields 1.0-phetio ()

circuit-construction-kit-ac 1.0 ()

circuit-construction-kit-ac-virtual-lab 1.0 ()

circuit-construction-kit-dc 1.3 ()

circuit-construction-kit-dc-virtual-lab 1.3 ()

collision-lab 1.1 ()

color-vision 1.1 ()

color-vision 1.2-phetio ()

concentration 1.5-phetio ()

concentration 1.7 ()

coulombs-law 1.0 ()

curve-fitting 1.0 ()

density 1.0 ()

diffusion 1.0 ()

energy-forms-and-changes 1.4 ()

energy-skate-park 1.2 ()

energy-skate-park-basics 1.1 ()

energy-skate-park-basics 1.3-phetio ()

equality-explorer 1.1 ()

equality-explorer-basics 1.0 ()

equality-explorer-two-variables 1.0 ()

expression-exchange 1.1 ()

faradays-law 1.3-phetio ()

faradays-law 1.4 ()

forces-and-motion-basics 2.1-phetio ()

forces-and-motion-basics 2.3 ()

fourier-making-waves 1.0 ()

fraction-matcher 1.2 ()

fractions-equality 1.1 ()

fractions-intro 1.0 ()

fractions-mixed-numbers 1.0 ()

friction 1.6 ()

function-builder 1.2 ()

function-builder-basics 1.2 ()

gas-properties 1.0 ()

gases-intro 1.0 ()

gene-expression-essentials 1.0 ()

geometric-optics 1.1 ()

geometric-optics-basics 1.2 ()

graphing-lines 1.3 ()

graphing-quadratics 1.2 ()

graphing-slope-intercept 1.1 ()

gravity-and-orbits 1.5 ()

gravity-and-orbits 1.6 ()

gravity-force-lab 2.2 ()

gravity-force-lab-basics 1.1 ()

greenhouse-effect 1.0 ()

greenhouse-effect 1.1 ()

hookes-law 1.0 ()

isotopes-and-atomic-mass 1.1 ()

john-travoltage 1.4-phetio ()

john-travoltage 1.6 ()

least-squares-regression 1.1 ()

make-a-ten 1.0 ()

masses-and-springs 1.0 ()

masses-and-springs-basics 1.0 ()

mean-share-and-balance 1.0 ()

molarity 1.4 ()

molarity 1.5 ()

molecule-polarity 1.2 ()

molecule-shapes 1.6 ()

molecule-shapes-basics 1.6 ()

molecules-and-light 1.3-phetio ()

molecules-and-light 1.5 ()

my-solar-system 1.0 ()

natural-selection 1.2 ()

natural-selection 1.3 ()

natural-selection 1.4 ()

neuron 1.1 ()

normal-modes 1.0 ()

number-compare 1.0 ()

number-line-distance 1.0 ()

number-line-integers 1.1 ()

number-line-operations 1.0 ()

number-play 1.1 ()

ohms-law 1.4 ()

pendulum-lab 1.0 ()

ph-scale 1.5 ()

ph-scale 1.6 ()

ph-scale-basics 1.5 ()

ph-scale-basics 1.6 ()

phet-io-test-sim 2.12 ()

plinko-probability 1.1 ()

projectile-motion 1.0 ()

proportion-playground 1.0 ()

ratio-and-proportion 1.2 ()

reactants-products-and-leftovers 1.2 ()

resistance-in-a-wire 1.3-phetio ()

resistance-in-a-wire 1.6 ()

rutherford-scattering 1.1 ()

states-of-matter 1.2 ()

states-of-matter-basics 1.2 ()

trig-tour 1.0 ()

under-pressure 1.1 ()

unit-rates 1.0 ()

vector-addition 1.0 ()

vector-addition-equations 1.0 ()

wave-interference 2.0 ()

wave-on-a-string 1.1 ()

waves-intro 1.1 ()

@jonathanolson
Copy link
Contributor Author

Verified that all production releases completed successfully.

@mattpen
Copy link
Contributor

mattpen commented May 15, 2023

@jonathanolson and I successfully adapted the build-server today to use the translated screen names based on the sim's package.json and the relevant babel files. I confirmed that this is working as expected with a production deploy of example-sim v1.2. This reduced the amount of time needed for screen names from 3-5 minutes to less than 1 second! @jonathanolson - is there anything else to do here?

@mattpen mattpen removed their assignment May 15, 2023
@jonathanolson
Copy link
Contributor Author

Nothing else to do, closing!

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

No branches or pull requests

2 participants