-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add flag to identify a11y strings in strings_*.json #193
Comments
Coassigning, @jbphet maybe we could pair on this? Or if you don't have time for it, I bet this could go into my a11y time, so I will be able to get to this sooner =). |
Yes, adding a flag to identify strings that are only for accessibility seems like the way to go. I think that the semantics of that flag will need to be that the string is used only for accessibility. In other words, if there is a string that serves a dual purpose in that it is visually displayed to the user and is also used for accessibility (and feel free to speak up if we never expect this situation to arise), the flag is not set on that string. Also, @jessegreenberg mentioned possibly using something like |
I'd like to be involved in the initial planning on this, and then I think @zepumph can take it from there. Since I'm not too clear on the priority of this, can either @jessegreenberg or @zepumph set up a meeting when it becomes time to get going on this and include me? |
I expect that strings will serve dual purposes. A This issue isn't critical, but the sooner it can be added the better so we don't keep creating SimA11yStrings.js files. |
I think I am beginning to understand what @jessegreenberg is speaking about. @jbphet mentioned two situations: 1: not a11y string for visual text (I think we all agree on this) I believe what @jessegreenberg is speaking to may be best described with an example. Sim 1 is published with a11y features that want to be translated. Sim 2 is published without any a11y support. Both simulations were published after instrumenting a Common Code Node 1 (CCN1) with a11y. To be clear this means that both sims have an a11y specific string inside of them meant for CCN1. So when we flip a switch and want to translate a11y features, both technically "have" the a11y strings needed for CCN1, but Sim 2 has a11y hidden behind a query parameter, never mean for use publically/in production. We probably don't want those a11y strings populating the translation utility for Sim 2. We need some sort of way to decipher whether or not to populate Translation X with common code string Y based on if the sim being translated for Translation X is implemented in a11y to a point where that string is needed. |
Notes from Zoom discussion with @jessegreenberg, @zepumph, and myself on 6/27/2018:
Marking for developer meeting to get input on each of the above items from the dev team. |
A phet-brand build of Build an Atom is 1.8MB. 15% of that is 270KB. For comparison, Node.js is 5160 LOC and 202KB.
Why can't PhET do that work now? It will take us N hours to implement a workaround to suppress a11y strings vs M hours to provide a way to see and test a11y strings (along with all the strings). How many hours do we have to work on this? In the long run, we want all of the a11y text translated--let's focus on providing translators ways to see and test the strings rather than a way to suppress the strings. |
It minifies to ~36 kB, which is significantly less. I'm not sure this comparison applies.
I'm also interested in this. Presumably we'll need other string metadata in the future.
Presumably we could include the metadata once per string (instead of once per each string+locale combination)?
Sounds workable. |
This issue was reviewed in the 7/5/2018 developer meeting and we made decisions on three of the four items above. Summarizing:
We should go with the approach of leaving the strings as they are in the sims and using the data from GitHub to determine whether a string is only for a11y. This minimizes impact to the size and structure of sims, and the metadata isn't needed during runtime. If there ever comes a time when the metadata is needed at runtime, we will revisit.
We should go with the suggested approach, which is to have a file in the rosetta repo that tracks the list of sims for which the a11y string should be presented for translation. At some point in the future, all sims will support this if they have a11y strings, but that time is probably at least one year out.
No objections to this. The remaining open issue concerns how to modify the rosetta UI to give the user the option of supporting a11y strings. I'd like some input from @ariel-phet and @emily-phet on this. Specific questions are: @emily-phet - what is the desired time from for supporting translation of a11y strings? @ariel-phet - How much effort should we put into the UI changes and who should work on the design? It could be something as simple as a checkbox that says "Show accessibility strings" at the top of the page, but if we'd like anything more than that we should have a design meeting and potentially do some mockups. |
It would be nice to show something like the a11y-view, so that translators can see the a11y strings better. |
@zepumph and @jessegreenberg - how would you like to proceed on actually moving the strings into the string files? I was thinking that we'd log an issue per repo that currently has a11y strings in another file, but you guys are the experts so you should chime in. |
That would be very nice!
Sounds great, plus common code repos. There currently 14 of these files. |
I'm not totally clear on this, because all sims have joist, and so will have joist's a11y strings in them, even if they don't have and accessibility content. As a result I think we need to design this solution in a way that recognizes that it will need to be around for a very long time. This manual file approach seems like it will be a pain once we are managing 20 a11y sims in a year, but all 100 other HTML sims (yay optimism) still have will end up requiring a11y strings that we don't want translated. What if we had a two pronged solution.
That allows flexibility for a less manual approach in the future.
Since this is not top priority for the a11y project right now, I think an issue per repo is a good idea, with a "chip-away" mindset, but I would suspect that many of these may sit around for a while. I will be in friction over the coming months, and @mbarlow12 is in faradays-law right now, so maybe we could use those as test cases. Also JT and OL with sonification are (hopefully) on the docket for publishing in September, so they could be good to try to implement this with too.
right now the a11y view is built with every build, but it is filtered out and not copied into production builds. One potential, minimal solution would be to publish the a11y view, and then load that (in an iframe or something) on the translation page, just so translators can see the english version. Stage 2 of that would be some way to manually feed temp strings into a new instance of the a11y view as a "testing mode" (I think we do that right now for normal sims), although URL length may become a problem. |
I merged master into the branches, but still didn't see the expected console.log output. |
@zepumph and I discussed this and it is looking good. Some ideas going forward: (1) maybe we can generalize the code in ChipperStringUtils.getStringFromMap to recursively check // Search suffixes or children equally
harvestPathsAll(string,country,locale,english){
if (harvestPaths(string,country)){
}else(harvestPaths(string,locale){}
...
}
const results = harvestPathsAll(...);
// prevent collisions like {my.name} vs {my{name}}
assert && assert(results.length===1, 'should have only one hit'); |
We may also be able to use this function in replacement of |
After more discussion with @samreid, here are some notes: goals:
cases to support:
maybe we create a TranslatableStringUtil.js that has all the string code used in all the above cases.
Next Steps:
where are fallback strings integrated with preferred locale strings? |
Some review comments from the branch:
|
Much of the above was completed at the end of phetsims/chipper#786. |
…rEachString to ignore arrays, phetsims/rosetta#193
Lots of work has been done on this issue today. In general this was just cleanup for the implementation over in phetsims/chipper#786. It was decided there to focus on requirejs/build mode in sims. We added nested string objects only in English JSON files, all other locales are still flat. Furthermore the build string map is flat. Keeping this implementation meant that no rosetta code had to be touched to support this. We were able to factor out most logic shared by requirejs (string plugin) and build mode (getStringMap) into Here is a list of further work that will be done in separate issues:
I'm going to assign this over to @samreid to review. In #193 (comment) it looked like you started a review, and even though we talked this morning. I wanted to make sure that you had a final time to look through what you wanted to. |
It would be nice to inline forEachStringImplementation, could be done like so: Index: js/common/ChipperStringUtils.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/common/ChipperStringUtils.js (revision 163a9b419b1960719c0b64417fd5c977e6d557d5)
+++ js/common/ChipperStringUtils.js (date 1569338689828)
@@ -168,35 +168,26 @@
* Call a function on each object with a value attribute in an object tree.
* @param {Object.<string, Object|{value:string}>} map - string map, like a loaded JSON strings file
* @param {function(key:string, {value:string})} func
+ * @param {string} [keySoFar] - as we recurse down, build up a string of the key separated with dots.
* @public
*/
- forEachString( map, func ) {
- forEachStringImplementation( '', map, func );
- }
- };
-
- /**
- * This implementation function helps keep a better api for `forEachString`.
- * @param {string} keySoFar - as we recurse down, build up a string of the key separated with dots.
- * @param {StringMapNode} map
- * @param {function(key:string, StringObject)} func
- */
- const forEachStringImplementation = ( keySoFar, map, func ) => {
- for ( const key in map ) {
- if ( map.hasOwnProperty( key ) ) {
- const nextKey = keySoFar ? `${keySoFar}.${key}` : key; // don't start with period, assumes '' is falsey
- const stringObject = map[ key ];
+ forEachString( map, func, keySoFar = '' ) {
+ for ( const key in map ) {
+ if ( map.hasOwnProperty( key ) ) {
+ const nextKey = keySoFar ? `${keySoFar}.${key}` : key; // don't start with period, assumes '' is falsey
+ const stringObject = map[ key ];
- // no need to support arrays in the string map, for example stringObject.history in locale specific files.
- if ( Array.isArray( stringObject ) ) {
- return;
- }
- if ( stringObject.value ) {
- func( nextKey, stringObject );
- }
+ // no need to support arrays in the string map, for example stringObject.history in locale specific files.
+ if ( Array.isArray( stringObject ) ) {
+ return;
+ }
+ if ( stringObject.value ) {
+ func( nextKey, stringObject );
+ }
- // recurse to the next level since if it wasn't the `value` key
- key !== 'value' && forEachStringImplementation( nextKey, stringObject, func );
+ // recurse to the next level since if it wasn't the `value` key
+ key !== 'value' && ChipperStringUtils.forEachString( stringObject, func, nextKey );
+ }
}
}
}; |
Agreed! Implemented above, and I updated the documentation too to use the |
Everything else seems good, thanks for your work on this! We will continue in the related issues mentioned above. Closing. |
Hopefully this is the right place for this issue.
We have translatable strings in sim-strings_*.json, and all a11y strings in some file like SimA11yStrings.js. Separation is so that a11y strings are not translatable. We hope to have them translatable someday, but PhET can't do that work now.
In the meantime, it was recommended that we add some flag to string entries like
accessible: true
orvisible: false
oraccessibleVisible: false
to signify that these strings are invisible and only available with an assistive device. With this flag, they won't show up at all in the translation utility.This way, all strings will be in one place, we can delete the SimA11yStrings.js files, and it will be easier to enable i18n for these strings when the time comes.
@jbphet does this still seem reasonable? This would hold us over until a11y is fully ready for i18n, so probably not worthwhile if you think it would take much time.
The text was updated successfully, but these errors were encountered: