Skip to content

Commit

Permalink
more robust a11y string conventions, #108
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Mar 15, 2018
1 parent 1aaf032 commit 154281f
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 107 deletions.
214 changes: 157 additions & 57 deletions js/ohms-law/OhmsLawA11yStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ define( function( require ) {
var ohmsLaw = require( 'OHMS_LAW/ohmsLaw' );

var OhmsLawA11yStrings = {
resistanceUnitsPatternString: '{{value}} Ohms',
voltageUnitsPatternString: '{{value}} Volts',
resistanceSliderLabelString: 'R, Resistance',
voltageSliderLabelString: 'V, Voltage',
resistanceUnitsPattern: {
value: '{{value}} Ohms'
},
voltageUnitsPattern: {
value: '{{value}} Volts'
},
resistanceSliderLabel: {
value: 'R, Resistance'
},
voltageSliderLabel: {
value: 'V, Voltage'
},

// accessible title for Ohms Law
ohmsLawTitleString: 'Ohm\'s Law',
ohmsLawTitle: {
value: 'Ohm\'s Law'
},

//--------------------------------------------------------------------------
// Relative size strings
Expand All @@ -28,95 +38,185 @@ define( function( require ) {
// descriptions for the size of the current arrows
// Note: Don't change number of sizes without changing the number of sizes value
numberOfSizes: 6,
tinyString: 'Tiny',
verySmallString: 'Very small',
smallString: 'Small',
mediumSizeString: 'Medium size',
largeString: 'Large',
veryLargeString: 'Very large',
hugeString: 'Huge',
tiny: {
value: 'Tiny'
},
verySmall: {
value: 'Very small'
},
small: {
value: 'Small'
},
mediumSize: {
value: 'Medium size'
},
large: {
value: 'Large'
},
veryLarge: {
value: 'Very large'
},
huge: {
value: 'Huge'
},

// relative descriptions that compare size of equation variables
muchMuchSmallerThanString: 'much much smaller than',
muchSmallerThanString: 'much smaller than',
slightlySmallerThanString: 'slightly smaller than',
comparableToString: 'comparable to',
slightlyLargerThanString: 'slightly larger than',
muchLargerThanString: 'much larger than',
muchMuchLargerThanString: 'much much larger than',
muchMuchSmallerThan: {
value: 'much much smaller than'
},
muchSmallerThan: {
value: 'much smaller than'
},
slightlySmallerThan: {
value: 'slightly smaller than'
},
comparableTo: {
value: 'comparable to'
},
slightlyLargerThan: {
value: 'slightly larger than'
},
muchLargerThan: {
value: 'much larger than'
},
muchMuchLargerThan: {
value: 'much much larger than'
},

// pattern for the description of relative letter size
relativeSizePatternString: 'In equation, <strong>letter V</strong> is <em>{{iComparison}}</em> <strong>letter I</strong> and <em>{{rComparison}}</em> <strong>letter R</strong>.',
relativeSizePattern: {
value: 'In equation, <strong>letter V</strong> is <em>{{iComparison}}</em> <strong>letter I</strong> and <em>{{rComparison}}</em> <strong>letter R</strong>.'
},

//--------------------------------------------------------------------------
// Equation strings
//--------------------------------------------------------------------------
ohmsLawEquationString: 'Ohm\'s Law Equation',
ohmsLawDefinitionString: 'Voltage, <strong>V</strong>, is equal to Current, <strong>I</strong>, times Resistance, <strong>R</strong>.',
ohmsLawEquation: {
value: 'Ohm\'s Law Equation'
},
ohmsLawDefinition: {
value: 'Voltage, <strong>V</strong>, is equal to Current, <strong>I</strong>, times Resistance, <strong>R</strong>.'
},

//--------------------------------------------------------------------------
// Circuit strings
//--------------------------------------------------------------------------
circuitLabelString: 'The Circuit',
circuitDescriptionString: 'A pair of wires connect a resistor to a series of batteries. In circuit, ',
circuitLabel: {
value: 'The Circuit'
},
circuitDescription: {
value: 'A pair of wires connect a resistor to a series of batteries. In circuit, '
},

//--------------------------------------------------------------------------
// Battery strings
//--------------------------------------------------------------------------

batteriesSupplyPatternString: 'batteries supply <em>{{voltage}} volts</em>',
batteriesSupplyPattern: {
value: 'batteries supply <em>{{voltage}} volts</em>'
},

//--------------------------------------------------------------------------
// Current strings
//--------------------------------------------------------------------------
currentDescriptionPatternString: '<em>{{arrowSize}} arrows</em> indicate a current flowing clockwise at <em>{{value}} milliamps</em>',
currentDescriptionPattern: {
value: '<em>{{arrowSize}} arrows</em> indicate a current flowing clockwise at <em>{{value}} milliamps</em>'
},

//--------------------------------------------------------------------------
// Resistance strings
//--------------------------------------------------------------------------

tinyAmountOfImpuritiesString: 'a tiny amount of impurities',
verySmallAmountOfImpuritiesString: 'a very small amount of impurities',
smallAmountOfImpuritiesString: 'a small amount of impurities',
mediumAmountOfImpuritiesString: 'a medium amount of impurities',
largeAmountOfImpuritiesString: 'a large amount of impurities',
veryLargeAmountOfImpuritiesString: 'a very large amount of impurities',
hugeAmountOfImpuritiesString: 'a huge amount of impurities',

resistanceDotsPatternString: 'resistor shows <em>{{impurities}}</em>',
tinyAmountOfImpurities: {
value: 'a tiny amount of impurities'
},
verySmallAmountOfImpurities: {
value: 'a very small amount of impurities'
},
smallAmountOfImpurities: {
value: 'a small amount of impurities'
},
mediumAmountOfImpurities: {
value: 'a medium amount of impurities'
},
largeAmountOfImpurities: {
value: 'a large amount of impurities'
},
veryLargeAmountOfImpurities: {
value: 'a very large amount of impurities'
},
hugeAmountOfImpurities: {
value: 'a huge amount of impurities'
},

resistanceDotsPattern: {
value: 'resistor shows <em>{{impurities}}</em>'
},

//--------------------------------------------------------------------------
// Scene summary strings
//--------------------------------------------------------------------------

// pattern for the current arrow description in the scene summary
summaryCurrentPatternString: '<em>{{size}}</em> arrows indicate amount of current flowing clockwise at {{current}} milliamps.',
summaryLookForSlidersString: 'Look for voltage and resistance sliders to play, or read on for details about equation and circuit.',
summarySimString: 'This is an interactive sim. Descriptions change as you play with it. It has a Play Area and ' +
'Control Panel. In the Play Area you find the equation for Ohm\'s Law, <strong>V</strong> equals ' +
'<strong>I</strong> times <strong>R</strong>, and a ' + 'circuit. Voltage and resistance sliders ' +
'allow changes to the equaltion and circuit. In the Control Panel, buttons mute sound or reset the sim.',

stateOfSimString: 'State of Sim',
rightNowString: 'Right now,',

voltageSummaryPatternString: 'voltage, <strong>V</strong>, is <em>{{value}} volts</em>',
resistanceSummaryPatternString: 'resistance, <strong>R</strong>, is <em>{{value}} ohms</em>',
currentSummaryPatternString: 'current, <strong>I</strong>, is <em>{{value}} milliamps</em>',
summaryCurrentPattern: {
value: '<em>{{size}}</em> arrows indicate amount of current flowing clockwise at {{current}} milliamps.'
},
summaryLookForSliders: {
value: 'Look for voltage and resistance sliders to play, or read on for details about equation and circuit.'
},
summarySim: {
value: 'This is an interactive sim. Descriptions change as you play with it. It has a Play Area and ' +
'Control Panel. In the Play Area you find the equation for Ohm\'s Law, <strong>V</strong> equals ' +
'<strong>I</strong> times <strong>R</strong>, and a ' + 'circuit. Voltage and resistance sliders ' +
'allow changes to the equaltion and circuit. In the Control Panel, buttons mute sound or reset the sim.'
},

stateOfSim: {
value: 'State of Sim'
},
rightNow: {
value: 'Right now,'
},

voltageSummaryPattern: {
value: 'voltage, <strong>V</strong>, is <em>{{value}} volts</em>'
},
resistanceSummaryPattern: {
value: 'resistance, <strong>R</strong>, is <em>{{value}} ohms</em>'
},
currentSummaryPattern: {
value: 'current, <strong>I</strong>, is <em>{{value}} milliamps</em>'
},


//--------------------------------------------------------------------------
// slider strings
//--------------------------------------------------------------------------
sliderControlsString: 'Slider Controls',
slidersDescriptionString: 'Voltage and resistance sliders allow changes to equation and circuit.',

sliderChangeAlertPatternString: 'As letter {{initLetter}} {{initSizeChange}}, letter I {{iSizeChange}}. Current now {{currentVal}} milliamps.',
letterRString: 'R',
letterVString: 'V',
shrinksString: 'shrinks',
growsString: 'grows',
aLotString: 'a lot'
sliderControls: {
value: 'Slider Controls'
},
slidersDescription: {
value: 'Voltage and resistance sliders allow changes to equation and circuit.'
},

sliderChangeAlertPattern: {
value: 'As letter {{initLetter}} {{initSizeChange}}, letter I {{iSizeChange}}. Current now {{currentVal}} milliamps.'
},
letterR: {
value: 'R'
},
letterV: {
value: 'V'
},
shrinks: {
value: 'shrinks'
},
grows: {
value: 'grows'
},
aLot: {
value: 'a lot'
}
};

if ( phet.chipper.queryParameters.stringTest === 'xss' ) {
Expand Down
28 changes: 14 additions & 14 deletions js/ohms-law/OhmsLawConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ define( function( require ) {
var RangeWithValue = require( 'DOT/RangeWithValue' );

// a11y strings
var tinyString = OhmsLawA11yStrings.tinyString;
var verySmallString = OhmsLawA11yStrings.verySmallString;
var smallString = OhmsLawA11yStrings.smallString;
var mediumSizeString = OhmsLawA11yStrings.mediumSizeString;
var largeString = OhmsLawA11yStrings.largeString;
var veryLargeString = OhmsLawA11yStrings.veryLargeString;
var hugeString = OhmsLawA11yStrings.hugeString;
var muchMuchSmallerThanString = OhmsLawA11yStrings.muchMuchSmallerThanString;
var muchSmallerThanString = OhmsLawA11yStrings.muchSmallerThanString;
var slightlySmallerThanString = OhmsLawA11yStrings.slightlySmallerThanString;
var comparableToString = OhmsLawA11yStrings.comparableToString;
var slightlyLargerThanString = OhmsLawA11yStrings.slightlyLargerThanString;
var muchLargerThanString = OhmsLawA11yStrings.muchLargerThanString;
var muchMuchLargerThanString = OhmsLawA11yStrings.muchMuchLargerThanString;
var tinyString = OhmsLawA11yStrings.tiny.value;
var verySmallString = OhmsLawA11yStrings.verySmall.value;
var smallString = OhmsLawA11yStrings.small.value;
var mediumSizeString = OhmsLawA11yStrings.mediumSize.value;
var largeString = OhmsLawA11yStrings.large.value;
var veryLargeString = OhmsLawA11yStrings.veryLarge.value;
var hugeString = OhmsLawA11yStrings.huge.value;
var muchMuchSmallerThanString = OhmsLawA11yStrings.muchMuchSmallerThan.value;
var muchSmallerThanString = OhmsLawA11yStrings.muchSmallerThan.value;
var slightlySmallerThanString = OhmsLawA11yStrings.slightlySmallerThan.value;
var comparableToString = OhmsLawA11yStrings.comparableTo.value;
var slightlyLargerThanString = OhmsLawA11yStrings.slightlyLargerThan.value;
var muchLargerThanString = OhmsLawA11yStrings.muchLargerThan.value;
var muchMuchLargerThanString = OhmsLawA11yStrings.muchMuchLargerThan.value;

// constants used by other constants
var RESISTANCE_RANGE = new RangeWithValue( 10, 1000, 500 ); // in ohms
Expand Down
2 changes: 1 addition & 1 deletion js/ohms-law/view/BatteriesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define( function( require ) {
var Util = require( 'DOT/Util' );

// a11y strings
var batteriesSupplyPatternString = OhmsLawA11yStrings.batteriesSupplyPatternString;
var batteriesSupplyPatternString = OhmsLawA11yStrings.batteriesSupplyPattern.value;

/**
* @param {Property.<number>} voltageProperty
Expand Down
24 changes: 12 additions & 12 deletions js/ohms-law/view/ControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ define( function( require ) {

// a11y strings - these strings are not meant to be translatable until the translation utility
// can provide translators with context
var resistanceUnitsPatternString = OhmsLawA11yStrings.resistanceUnitsPatternString;
var voltageUnitsPatternString = OhmsLawA11yStrings.voltageUnitsPatternString;
var resistanceSliderLabelString = OhmsLawA11yStrings.resistanceSliderLabelString;
var voltageSliderLabelString = OhmsLawA11yStrings.voltageSliderLabelString;
var sliderControlsString = OhmsLawA11yStrings.sliderControlsString;
var slidersDescriptionString = OhmsLawA11yStrings.slidersDescriptionString;
var resistanceUnitsPatternString = OhmsLawA11yStrings.resistanceUnitsPattern.value;
var voltageUnitsPatternString = OhmsLawA11yStrings.voltageUnitsPattern.value;
var resistanceSliderLabelString = OhmsLawA11yStrings.resistanceSliderLabel.value;
var voltageSliderLabelString = OhmsLawA11yStrings.voltageSliderLabel.value;
var sliderControlsString = OhmsLawA11yStrings.sliderControls.value;
var slidersDescriptionString = OhmsLawA11yStrings.slidersDescription.value;

// a11y strings
var sliderChangeAlertPatternString = OhmsLawA11yStrings.sliderChangeAlertPatternString;
var letterRString = OhmsLawA11yStrings.letterRString;
var letterVString = OhmsLawA11yStrings.letterVString;
var shrinksString = OhmsLawA11yStrings.shrinksString;
var growsString = OhmsLawA11yStrings.growsString;
var aLotString = OhmsLawA11yStrings.aLotString;
var sliderChangeAlertPatternString = OhmsLawA11yStrings.sliderChangeAlertPattern.value;
var letterRString = OhmsLawA11yStrings.letterR.value;
var letterVString = OhmsLawA11yStrings.letterV.value;
var shrinksString = OhmsLawA11yStrings.shrinks.value;
var growsString = OhmsLawA11yStrings.grows.value;
var aLotString = OhmsLawA11yStrings.aLot.value;

// constants
var NUMBER_OF_LETTER_SIZES = OhmsLawA11yStrings.numberOfSizes; // a11y - the number of sizes that letters can be described as.
Expand Down
6 changes: 3 additions & 3 deletions js/ohms-law/view/FormulaNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ define( function( require ) {
var voltageSymbolString = require( 'string!OHMS_LAW/voltageSymbol' );

// a11y strings
var relativeSizePatternString = OhmsLawA11yStrings.relativeSizePatternString;
var ohmsLawEquationString = OhmsLawA11yStrings.ohmsLawEquationString;
var ohmsLawDefinitionString = OhmsLawA11yStrings.ohmsLawDefinitionString;
var relativeSizePatternString = OhmsLawA11yStrings.relativeSizePattern.value;
var ohmsLawEquationString = OhmsLawA11yStrings.ohmsLawEquation.value;
var ohmsLawDefinitionString = OhmsLawA11yStrings.ohmsLawDefinition.value;

// constants
var TEXT_FONT = new PhetFont( { family: OhmsLawConstants.FONT_FAMILY, size: 20, weight: 'bold' } );
Expand Down
16 changes: 8 additions & 8 deletions js/ohms-law/view/OhmsLawSceneSummaryNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ define( function( require ) {
var Util = require( 'DOT/Util' );

// strings
var summaryLookForSlidersString = OhmsLawA11yStrings.summaryLookForSlidersString;
var sceneSummaryString = JoistA11yStrings.sceneSummaryString.value;
var summarySimString = OhmsLawA11yStrings.summarySimString;
var rightNowString = OhmsLawA11yStrings.rightNowString;
var voltageSummaryPatternString = OhmsLawA11yStrings.voltageSummaryPatternString;
var resistanceSummaryPatternString = OhmsLawA11yStrings.resistanceSummaryPatternString;
var currentSummaryPatternString = OhmsLawA11yStrings.currentSummaryPatternString;
var checkOutShortcutsString = JoistA11yStrings.checkOutShortcutsString.value;
var summaryLookForSlidersString = OhmsLawA11yStrings.summaryLookForSliders.value;
var sceneSummaryString = JoistA11yStrings.sceneSummary.value;
var summarySimString = OhmsLawA11yStrings.summarySim.value;
var rightNowString = OhmsLawA11yStrings.rightNow.value;
var voltageSummaryPatternString = OhmsLawA11yStrings.voltageSummaryPattern.value;
var resistanceSummaryPatternString = OhmsLawA11yStrings.resistanceSummaryPattern.value;
var currentSummaryPatternString = OhmsLawA11yStrings.currentSummaryPattern.value;
var checkOutShortcutsString = JoistA11yStrings.checkOutShortcuts.value;

function OhmsLawSceneSummaryNode( model ) {

Expand Down
2 changes: 1 addition & 1 deletion js/ohms-law/view/OhmsLawScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ define( function( require ) {
var REMOVE_BATTERY_SOUND = new Sound( require( 'audio!OHMS_LAW/remove-battery' ) );

// a11y strings
var ohmsLawTitleString = OhmsLawA11yStrings.ohmsLawTitleString;
var ohmsLawTitleString = OhmsLawA11yStrings.ohmsLawTitle.value;
var playAreaString = JoistA11yStrings.playAreaString.value;
var controlPanelString = JoistA11yStrings.controlPanelString.value;

Expand Down
Loading

0 comments on commit 154281f

Please sign in to comment.