Skip to content

Commit

Permalink
don't add directional formatting to a11y strings, #798
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 30, 2019
1 parent ba4f356 commit 13d7649
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion js/common/ChipperStringUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// What divides the repo prefix from the rest of the string key, like `FRICTION/friction.title`
const NAMESPACE_PREFIX_DIVIDER = '/';
const A11Y_MARKER = 'a11y.';

const ChipperStringUtils = {

Expand Down Expand Up @@ -127,7 +128,11 @@

// remove leading/trailing whitespace, see chipper#619. Do this before addDirectionalFormatting
stringObject.value = stringObject.value.trim();
stringObject.value = ChipperStringUtils.addDirectionalFormatting( stringObject.value, isRTL );

// A11Y can't support i18n with this conditional in, this is more of a workaround, see https://github.com/phetsims/chipper/issues/798
if ( !ChipperStringUtils.isA11yStringKey( key ) ) {
stringObject.value = ChipperStringUtils.addDirectionalFormatting( stringObject.value, isRTL );
}
} );
},

Expand Down Expand Up @@ -164,6 +169,15 @@
return null;
},

/**
* @public
* @param {string} key - without "string!REPO" at the beginning, just the actual "string key"
* @returns {boolean}
*/
isA11yStringKey( key ) {
return key.indexOf( ChipperStringUtils.A11Y_MARKER ) === 0;
},

/**
* 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
Expand Down

0 comments on commit 13d7649

Please sign in to comment.