Closed samreid closed 1 year ago
Patch from today's meeting:
Index: js/LocalizedString.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/LocalizedString.ts b/js/LocalizedString.ts
--- a/js/LocalizedString.ts (revision d2b106e08c42c805e082570609352aab5f39aefc)
+++ b/js/LocalizedString.ts (date 1661465048890)
@@ -53,7 +53,11 @@
this.property = new DynamicProperty( localeProperty, {
derive: ( locale: string ) => this.getLocaleSpecificProperty( locale ),
bidirectional: true,
- phetioReadOnly: false,
+
+ // Don't allow editing the joist credits
+ phetioReadOnly: tandem.phetioID.includes( '.joist.credits.' ) ||
+ tandem.phetioID.includes( 'joist.versionPatternStringProperty' ) ||
+ tandem.phetioID.includes( 'joist.termsPrivacyAndLicensingStringProperty' ),
phetioValueType: StringIO,
phetioState: false,
tandem: tandem,
How about this crazy idea!!?!?!?
That is much better than the previous iteration, thanks! Considering taking it one step further, what about this?
Index: joist-strings_en.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/joist-strings_en.json b/joist-strings_en.json
--- a/joist-strings_en.json (revision a5064217d68bd28986e9b6db82ea9d7df53cc6dc)
+++ b/joist-strings_en.json (date 1661477546163)
@@ -51,7 +51,8 @@
"value": "Software Development: {0}"
},
"credits.team": {
- "value": "Team: {0}"
+ "value": "Team: {0}",
+ "phetioReadOnly": true
},
"credits.contributors": {
"value": "Contributors: {0}"
We'd like to prevent clients from editing the sim credits and other contents of the About dialog. Let's make these strings phetioReadOnly: true
.
strings.joist.termsPrivacyAndLicensingStringProperty
strings.joist.versionPatternStringProperty
strings.joist.credits.*
strings.joist.thirdParty.credits.linkStringProperty
strings.joist.translation.credits.linkStringProperty
I don't yet feel like I have a good solution for how to do this. It makes me incredibly worried to put this data into the string files, but perhaps that is an acceptable solution. I won't be able to investigate this soon. @samreid, would you mind trying out putting the data in string files, and seeing what you need to do to load-unbuilt-strings and getStringModule to have this work in both (un)built modes?
Before committing, we would want to double check with rosetta team that they are depending on a specific structure of phet.chipper.strings or somethign.
@jbphet or @liammulh does the above proposal sound reasonable to you?
I could be wrong, but I don't think this (the most recent patch) will negatively affect rosetta since it doesn't look for anything other than stringKey.value. @jbphet, what say you?
@samreid, just to be clear here, the object returned by getStringModule most likely shouldn't change at all. We only need to store this data in phet.chipper.strings, which will be used to create the Properties in that object, but we don't need to put phetioReadOnly
into that object used by sims.
Some ideas:
"menuItem.phetWebsite": {
"value": "PhET Website\u2026",
"phet-ioMetadata": {},
"phetioMetadata": {},
"_metadata": {},
"metadata": {
"phetioReadOnly": true
},
"phetioReadOnly": true
},
We looked at this today at PhET-iO design meeting, @jbphet can you please comment here as to if adding this metadata to the en json string files would be alright from a rosetta/translation perspective?
@jonathanolson recommends keeping it out of phet.chipper.strings, because that is more of a per-locale data structure, so we will just want to create our own metadata object that can be used in getStringModule.
We need to support this in getStringMap and load-unbuilt-strings.
Above, @zepumph asked:
@jbphet can you please comment here as to if adding this metadata to the en json string files would be alright from a rosetta/translation perspective?
In an earlier comment, he said:
It makes me incredibly worried to put this data into the string files...
In the comment immediately above this one, he said:
@jonathanolson recommends keeping it out of phet.chipper.strings, because that is more of a per-locale data structure, so we will just want to create our own metadata object that can be used in getStringModule.
So, at this point, I'm a little confused. Are we still talking about putting the metadata to mark a string as phetioReadOnly
in the English version of the strings file? If so, would it only be in the English file and not in the others? If we specifically know the strings that we want to be phetioReadOnly
and don't expect to create more of them during the development process, perhaps we should just make them a special case and handle it in the code, and not require additional information in the strings file(s).
I obviously have some concerns about this approach, but to specifically answer your question, I don't think adding this metadata to the English version of the strings file will negatively impact Rosetta. Rosetta will just ignore the information.
There's certain metadata for strings that apply to ALL locales, this seems to be an example (confirmed during design meeting). I propose that we keep that metadata in the file that is checked into the sim (which happens to be the English string file).
For the runtime of sims (built and unbuilt), that metadata doesn't fit well with what phet.chipper.strings
currently is. I recommend placing the metadata elsewhere (phet.chipper.stringData
?) that can be used by getStringModule.
@zepumph thoughts on:
"menuItem.phetWebsite": {
"value": "PhET Website\u2026",
"metadata": {
"phetioReadOnly": true
}
},
and phet.chipper.stringMetadata[ stringKey ]
is the content of everything under metadata?
So in getStringModule, near
const localizedString = new LocalizedString( phet.chipper.mapString( phet.chipper.strings[ FALLBACK_LOCALE ][ stringKey ] ), tandem );
we can just grab phet.chipper.stringMetadata[ stringKey ]?.phetioReadOnly
. We'll need to create options for LocalizedString.
load-unbuilt-strings will populate phet.chipper.stringMetadata
as it loads the English file.
We'll create getStringMetadata
(similar to getStringMap), to be used in buildRunnable, we'll include it in commonInitializationOptions, getInitializationScript() will be modified to include stringMetadata
, and chipper/templates/chipper-initialization.js will be modified to add a lint for the stringMetadata.
Thoughts? Should we collaborate on this, or schedule a time for it?
I'd love to take a first pass on this if you don't mind. I'll let you know how it goes!
Unfortunately I will not have time for this like I thought I would. @jonathanolson, can you please take the lead on it and work with @samreid for any PhET-iO questions?
Implemented, and added read-only to the strings in https://github.com/phetsims/joist/issues/845#issuecomment-1228885371.
@zepumph can you verify?
I'll review this issue, thanks @jonathanolson
I reviewed the places phetioReadOnly was marked true, and checked that they appeared correctly in studio. I tested built and unbuilt mode. I considered that we may one day want to put metadata in a parent node, like:
credits:{
phetioReadOnly: true,
author: {
// etc
}
But I believe that would be overcomplicated for now.
I think this issue can be closed, @kathy-phet do you recommend any further design or code review?
Review:
@arouinfar Here is the list that we marked as read only:
"termsPrivacyAndLicensing"
"credits.title"
"credits.leadDesign"
"credits.softwareDevelopment"
"credits.team"
"credits.contributors"
"credits.qualityAssurance"
"credits.graphicArts"
"credits.soundDesign"
"credits.translation"
"credits.thanks"
"options.title"
"versionPattern"
"translation.credits.link"
"thirdParty.credits.link"
@arouinfar does this look complete and correct?
Everything else looks great! Thanks all!
Yes, that all looks good @zepumph.
It sounds fine to move LocalizedString/getStringModule to joist, although that will make maintenance releases more difficult for getStringModule. @kathy-phet do you know if we would maintenance release anything like that?
No strong preference. Let's just keep getStringModel
in chipper.
@zepumph can this issue be closed?
@zepumph and I reviewed the issue and agreed it is ready to close. Thanks!
From https://github.com/phetsims/axon/issues/408