-
Notifications
You must be signed in to change notification settings - Fork 6
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
new sims are using old-style formatting patterns #446
Comments
I could be remembering incorrectly, but I thought we would use the new style ( An example is in masses-and-springs for use with NumberControl: valuePattern: StringUtils.fillIn( gravityValueString, {
gravity: '{0}'
} ), with the string: "gravityValue": {
"value": "{{gravity}} m/s<sup>2</sup>"
}, I also see this pattern being used a lot when searching for |
Raising priority since this is blocking phetsims/wave-interference#266. |
My recollection is the same as what @jonathanolson said in #446 (comment). But I thought we should revisit since (a) Wave Interference isn't using that pattern, and (b) it's not a great longterm solution. |
I volunteered for this at today's status meeting 12/20/18. The plan is to make NumberDisplay support both numbered and named placeholders, with the constrain that they be |
Something I ran into immediately when using named placeholders with NumberDisplay... Here's a typical example: const valueUnitsString = requirejs( ... ); // "{{value}} {{units}}"
...
const numberDisplay = new NumberDisplay( ..., {
format: StringUtils.fillIn( valueUnitsString, {
units: 'nm'
} )
} ); The above will fail because Does anyone object to changing the behavior of |
#446 (comment) got a 👍 on Slack. |
…nery-phet#446 Signed-off-by: Chris Malley <[email protected]>
…ntrol, #446 Signed-off-by: Chris Malley <[email protected]>
These repose are currently using the workaround to covert
|
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Summary of changes:
Since this issue was motivated by phetsims/wave-interference#266, @samreid would you please review? |
Unit test phetcommon/phetcommon-tests.html?ea is failing, can you please take a look before I review? |
Will do. I didn't realize that phetcommon had unit tests. |
So this:
should be changed to this:
|
There are other sims that are doing some wonky replacements of '{0}'.
|
I'll create sim-specific issues for all of the above. |
To prevent a proliferation of |
Sim-specific issues have been created for sims that are doing unnecessary replacement or should be using constants instead of string literals. Back to @samreid to continue review. |
I skimmed the commits and didn't see anything that requires further work. I added Back to @pixelzoom about this last point--close if all is well. |
Noted during Wave Interference code review phetsims/wave-interference#259.
Wave Interference, a new sim, is necessarily using old-style (numeric placeholders) formatting patterns:
New-style (named placeholders) would be:
I say "necessarily using" because we have common components (
NumberControl
,NumberDisplay
,...) that use this format.Creating more strings that use the old-style seems like something that we want to avoid.
Options, in order of increasing cost/complexity:
(1) Tolerate this and do nothing.
(2) Make client code adapter new-style patterns to UI components that use old-style components. E.g.
(3) Provide a utility for doing (2).
(4) Change the UI components to recognize both old-style and new-style.
(5) Change the UI components to use new-style, and change all existing translations.
The text was updated successfully, but these errors were encountered: