Skip to content

Commit

Permalink
Remove uppercase number words, see: #4
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Sep 27, 2024
1 parent 9f0cca5 commit 40fcf53
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 146 deletions.
21 changes: 0 additions & 21 deletions js/NumberPairsStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,26 @@ type StringsType = {
'equationStringProperty': LocalizedStringProperty;
'numberSentencePatternStringProperty': LocalizedStringProperty;
'zeroStringProperty': LocalizedStringProperty;
'uppercaseZeroStringProperty': LocalizedStringProperty;
'oneStringProperty': LocalizedStringProperty;
'uppercaseOneStringProperty': LocalizedStringProperty;
'twoStringProperty': LocalizedStringProperty;
'uppercaseTwoStringProperty': LocalizedStringProperty;
'threeStringProperty': LocalizedStringProperty;
'uppercaseThreeStringProperty': LocalizedStringProperty;
'fourStringProperty': LocalizedStringProperty;
'uppercaseFourStringProperty': LocalizedStringProperty;
'fiveStringProperty': LocalizedStringProperty;
'uppercaseFiveStringProperty': LocalizedStringProperty;
'sixStringProperty': LocalizedStringProperty;
'uppercaseSixStringProperty': LocalizedStringProperty;
'sevenStringProperty': LocalizedStringProperty;
'uppercaseSevenStringProperty': LocalizedStringProperty;
'eightStringProperty': LocalizedStringProperty;
'uppercaseEightStringProperty': LocalizedStringProperty;
'nineStringProperty': LocalizedStringProperty;
'uppercaseNineStringProperty': LocalizedStringProperty;
'tenStringProperty': LocalizedStringProperty;
'uppercaseTenStringProperty': LocalizedStringProperty;
'elevenStringProperty': LocalizedStringProperty;
'uppercaseElevenStringProperty': LocalizedStringProperty;
'twelveStringProperty': LocalizedStringProperty;
'uppercaseTwelveStringProperty': LocalizedStringProperty;
'thirteenStringProperty': LocalizedStringProperty;
'uppercaseThirteenStringProperty': LocalizedStringProperty;
'fourteenStringProperty': LocalizedStringProperty;
'uppercaseFourteenStringProperty': LocalizedStringProperty;
'fifteenStringProperty': LocalizedStringProperty;
'uppercaseFifteenStringProperty': LocalizedStringProperty;
'sixteenStringProperty': LocalizedStringProperty;
'uppercaseSixteenStringProperty': LocalizedStringProperty;
'seventeenStringProperty': LocalizedStringProperty;
'uppercaseSeventeenStringProperty': LocalizedStringProperty;
'eighteenStringProperty': LocalizedStringProperty;
'uppercaseEighteenStringProperty': LocalizedStringProperty;
'nineteenStringProperty': LocalizedStringProperty;
'uppercaseNineteenStringProperty': LocalizedStringProperty;
'twentyStringProperty': LocalizedStringProperty;
'uppercaseTwentyStringProperty': LocalizedStringProperty;
'addendsStringProperty': LocalizedStringProperty;
'tickNumbersStringProperty': LocalizedStringProperty;
'totalJumpStringProperty': LocalizedStringProperty;
Expand Down
97 changes: 36 additions & 61 deletions js/common/view/NumberSentenceAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,80 +9,55 @@
import numberPairs from '../../numberPairs.js';
import PatternStringProperty from '../../../../axon/js/PatternStringProperty.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';
import { RichText, Text, Node, Rectangle } from '../../../../scenery/js/imports.js';
import { Node, Rectangle, RichText, Text } from '../../../../scenery/js/imports.js';
import NumberPairsConstants from '../NumberPairsConstants.js';
import TotalRepresentationAccordionBox, { TotalRepresentationAccordionBoxOptions } from './TotalRepresentationAccordionBox.js';
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import NumberPairsModel from '../model/NumberPairsModel.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import DynamicProperty from '../../../../axon/js/DynamicProperty.js';

const LOWERCASE_NUMBER_TO_WORD_MAP = new Map();
LOWERCASE_NUMBER_TO_WORD_MAP.set( 0, NumberPairsStrings.zeroStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 1, NumberPairsStrings.oneStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 2, NumberPairsStrings.twoStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 3, NumberPairsStrings.threeStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 4, NumberPairsStrings.fourStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 5, NumberPairsStrings.fiveStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 6, NumberPairsStrings.sixStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 7, NumberPairsStrings.sevenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 8, NumberPairsStrings.eightStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 9, NumberPairsStrings.nineStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 10, NumberPairsStrings.tenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 11, NumberPairsStrings.elevenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 12, NumberPairsStrings.twelveStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 13, NumberPairsStrings.thirteenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 14, NumberPairsStrings.fourteenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 15, NumberPairsStrings.fifteenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 16, NumberPairsStrings.sixteenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 17, NumberPairsStrings.seventeenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 18, NumberPairsStrings.eighteenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 19, NumberPairsStrings.nineteenStringProperty );
LOWERCASE_NUMBER_TO_WORD_MAP.set( 20, NumberPairsStrings.twentyStringProperty );

const UPPERCASE_NUMBER_TO_WORD_MAP = new Map();
UPPERCASE_NUMBER_TO_WORD_MAP.set( 0, NumberPairsStrings.uppercaseZeroStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 1, NumberPairsStrings.uppercaseOneStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 2, NumberPairsStrings.uppercaseTwoStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 3, NumberPairsStrings.uppercaseThreeStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 4, NumberPairsStrings.uppercaseFourStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 5, NumberPairsStrings.uppercaseFiveStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 6, NumberPairsStrings.uppercaseSixStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 7, NumberPairsStrings.uppercaseSevenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 8, NumberPairsStrings.uppercaseEightStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 9, NumberPairsStrings.uppercaseNineStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 10, NumberPairsStrings.uppercaseTenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 11, NumberPairsStrings.uppercaseElevenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 12, NumberPairsStrings.uppercaseTwelveStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 13, NumberPairsStrings.uppercaseThirteenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 14, NumberPairsStrings.uppercaseFourteenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 15, NumberPairsStrings.uppercaseFifteenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 16, NumberPairsStrings.uppercaseSixteenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 17, NumberPairsStrings.uppercaseSeventeenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 18, NumberPairsStrings.uppercaseEighteenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 19, NumberPairsStrings.uppercaseNineteenStringProperty );
UPPERCASE_NUMBER_TO_WORD_MAP.set( 20, NumberPairsStrings.uppercaseTwentyStringProperty );
const NUMBER_TO_WORD_MAP = new Map();
NUMBER_TO_WORD_MAP.set( 0, NumberPairsStrings.zeroStringProperty );
NUMBER_TO_WORD_MAP.set( 1, NumberPairsStrings.oneStringProperty );
NUMBER_TO_WORD_MAP.set( 2, NumberPairsStrings.twoStringProperty );
NUMBER_TO_WORD_MAP.set( 3, NumberPairsStrings.threeStringProperty );
NUMBER_TO_WORD_MAP.set( 4, NumberPairsStrings.fourStringProperty );
NUMBER_TO_WORD_MAP.set( 5, NumberPairsStrings.fiveStringProperty );
NUMBER_TO_WORD_MAP.set( 6, NumberPairsStrings.sixStringProperty );
NUMBER_TO_WORD_MAP.set( 7, NumberPairsStrings.sevenStringProperty );
NUMBER_TO_WORD_MAP.set( 8, NumberPairsStrings.eightStringProperty );
NUMBER_TO_WORD_MAP.set( 9, NumberPairsStrings.nineStringProperty );
NUMBER_TO_WORD_MAP.set( 10, NumberPairsStrings.tenStringProperty );
NUMBER_TO_WORD_MAP.set( 11, NumberPairsStrings.elevenStringProperty );
NUMBER_TO_WORD_MAP.set( 12, NumberPairsStrings.twelveStringProperty );
NUMBER_TO_WORD_MAP.set( 13, NumberPairsStrings.thirteenStringProperty );
NUMBER_TO_WORD_MAP.set( 14, NumberPairsStrings.fourteenStringProperty );
NUMBER_TO_WORD_MAP.set( 15, NumberPairsStrings.fifteenStringProperty );
NUMBER_TO_WORD_MAP.set( 16, NumberPairsStrings.sixteenStringProperty );
NUMBER_TO_WORD_MAP.set( 17, NumberPairsStrings.seventeenStringProperty );
NUMBER_TO_WORD_MAP.set( 18, NumberPairsStrings.eighteenStringProperty );
NUMBER_TO_WORD_MAP.set( 19, NumberPairsStrings.nineteenStringProperty );
NUMBER_TO_WORD_MAP.set( 20, NumberPairsStrings.twentyStringProperty );

type SelfOptions = EmptySelfOptions;
type NumberSentenceAccordionBoxOptions = SelfOptions & StrictOmit<TotalRepresentationAccordionBoxOptions, 'titleNode'>;
export default class NumberSentenceAccordionBox extends TotalRepresentationAccordionBox {

public constructor( model: NumberPairsModel, providedOptions: NumberSentenceAccordionBoxOptions ) {

const numberSentencePatternStringProperty = new PatternStringProperty( NumberPairsStrings.numberSentencePatternStringProperty, {
sum: model.totalNumberProperty,
leftAddend: model.leftAddendNumberProperty,
rightAddend: model.rightAddendNumberProperty
}, {
maps: {
const totalStringProperty = new DerivedProperty( [ model.totalNumberProperty ],
total => NUMBER_TO_WORD_MAP.get( total ) );
const leftAddendStringProperty = new DerivedProperty( [ model.leftAddendNumberProperty ],
leftAddend => NUMBER_TO_WORD_MAP.get( leftAddend ) );
const rightAddendStringProperty = new DerivedProperty( [ model.rightAddendNumberProperty ],
rightAddend => NUMBER_TO_WORD_MAP.get( rightAddend ) );

// TODO: Pretty sure this will not work with translations. Didn't have time to address yet. Will tackle next.
// https://github.com/phetsims/number-pairs/issues/4
// I would like to chat with CM about this. I think it needs to be a DerivedProperty that passes through all the possible
// string Properties, but that sounds annoying...
sum: value => UPPERCASE_NUMBER_TO_WORD_MAP.get( value ).value,
leftAddend: value => LOWERCASE_NUMBER_TO_WORD_MAP.get( value ).value,
rightAddend: value => LOWERCASE_NUMBER_TO_WORD_MAP.get( value ).value
}
const numberSentencePatternStringProperty = new PatternStringProperty( NumberPairsStrings.numberSentencePatternStringProperty, {
total: new DynamicProperty( totalStringProperty ),
leftAddend: new DynamicProperty( leftAddendStringProperty ),
rightAddend: new DynamicProperty( rightAddendStringProperty )
} );

let totalHighlight: Rectangle;
Expand All @@ -92,7 +67,7 @@ export default class NumberSentenceAccordionBox extends TotalRepresentationAccor
lineWrap: 250,
leading: 10,
tags: {
sum: node => {
total: node => {
totalHighlight = new Rectangle( node.bounds.dilated( 1 ), {
fill: model.totalColorProperty.value
} );
Expand Down
65 changes: 1 addition & 64 deletions number-pairs-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,134 +27,71 @@
"value": "Equation"
},
"numberSentencePattern": {
"value": "<sum>{{sum}}</sum> can be decomposed into <left>{{leftAddend}}</left> and <right>{{rightAddend}}</right>."
"value": "<total>{{total}}</total> can be decomposed into <left>{{leftAddend}}</left> and <right>{{rightAddend}}</right>"
},
"zero": {
"value": "zero"
},
"uppercaseZero": {
"value": "Zero"
},
"one": {
"value": "one"
},
"uppercaseOne": {
"value": "One"
},
"two": {
"value": "two"
},
"uppercaseTwo": {
"value": "Two"
},
"three": {
"value": "three"
},
"uppercaseThree": {
"value": "Three"
},
"four": {
"value": "four"
},
"uppercaseFour": {
"value": "Four"
},
"five": {
"value": "five"
},
"uppercaseFive": {
"value": "Five"
},
"six": {
"value": "six"
},
"uppercaseSix": {
"value": "Six"
},
"seven": {
"value": "seven"
},
"uppercaseSeven": {
"value": "Seven"
},
"eight": {
"value": "eight"
},
"uppercaseEight": {
"value": "Eight"
},
"nine": {
"value": "nine"
},
"uppercaseNine": {
"value": "Nine"
},
"ten": {
"value": "ten"
},
"uppercaseTen": {
"value": "Ten"
},
"eleven": {
"value": "eleven"
},
"uppercaseEleven": {
"value": "Eleven"
},
"twelve": {
"value": "twelve"
},
"uppercaseTwelve": {
"value": "Twelve"
},
"thirteen": {
"value": "thirteen"
},
"uppercaseThirteen": {
"value": "Thirteen"
},
"fourteen": {
"value": "fourteen"
},
"uppercaseFourteen": {
"value": "Fourteen"
},
"fifteen": {
"value": "fifteen"
},
"uppercaseFifteen": {
"value": "Fifteen"
},
"sixteen": {
"value": "sixteen"
},
"uppercaseSixteen": {
"value": "Sixteen"
},
"seventeen": {
"value": "seventeen"
},
"uppercaseSeventeen": {
"value": "Seventeen"
},
"eighteen": {
"value": "eighteen"
},
"uppercaseEighteen": {
"value": "Eighteen"
},
"nineteen": {
"value": "nineteen"
},
"uppercaseNineteen": {
"value": "Nineteen"
},
"twenty": {
"value": "twenty"
},
"uppercaseTwenty": {
"value": "Twenty"
},
"addends": {
"value": "Addends"
},
Expand Down

0 comments on commit 40fcf53

Please sign in to comment.