Skip to content

Commit

Permalink
Rename NUMBER_TO_STRING_KEY_PRIMARY => NUMBER_TO_STRING_PROPERTY_PRIM…
Browse files Browse the repository at this point in the history
…ARY, see #13
  • Loading branch information
chrisklus committed Jan 30, 2023
1 parent cd1dfa4 commit 1fbf1a7
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions js/common/NumberSuiteCommonConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ import numberSuiteCommon from '../numberSuiteCommon.js';
import NumberSuiteCommonStrings from '../NumberSuiteCommonStrings.js';
import { SecondLocaleStrings } from './model/NumberSuiteCommonPreferences.js';

// Maps a number to the stringProperty of the translated word that corresponds to the number.
const NUMBER_TO_STRING_PROPERTY_PRIMARY: Record<number, LinkableProperty<string>> = {
0: NumberSuiteCommonStrings.zeroStringProperty,
1: NumberSuiteCommonStrings.oneStringProperty,
2: NumberSuiteCommonStrings.twoStringProperty,
3: NumberSuiteCommonStrings.threeStringProperty,
4: NumberSuiteCommonStrings.fourStringProperty,
5: NumberSuiteCommonStrings.fiveStringProperty,
6: NumberSuiteCommonStrings.sixStringProperty,
7: NumberSuiteCommonStrings.sevenStringProperty,
8: NumberSuiteCommonStrings.eightStringProperty,
9: NumberSuiteCommonStrings.nineStringProperty,
10: NumberSuiteCommonStrings.tenStringProperty,
11: NumberSuiteCommonStrings.elevenStringProperty,
12: NumberSuiteCommonStrings.twelveStringProperty,
13: NumberSuiteCommonStrings.thirteenStringProperty,
14: NumberSuiteCommonStrings.fourteenStringProperty,
15: NumberSuiteCommonStrings.fifteenStringProperty,
16: NumberSuiteCommonStrings.sixteenStringProperty,
17: NumberSuiteCommonStrings.seventeenStringProperty,
18: NumberSuiteCommonStrings.eighteenStringProperty,
19: NumberSuiteCommonStrings.nineteenStringProperty,
20: NumberSuiteCommonStrings.twentyStringProperty
};

// Maps a number to the key used to look up the translated word that corresponds to the number.
const NUMBER_TO_STRING_KEY_SECONDARY: Record<number, string> = {
0: 'zero',
Expand All @@ -37,30 +62,6 @@ const NUMBER_TO_STRING_KEY_SECONDARY: Record<number, string> = {
20: 'twenty'
} as Record<number, string>;

const NUMBER_TO_STRING_KEY_PRIMARY: Record<number, LinkableProperty<string>> = {
0: NumberSuiteCommonStrings.zeroStringProperty,
1: NumberSuiteCommonStrings.oneStringProperty,
2: NumberSuiteCommonStrings.twoStringProperty,
3: NumberSuiteCommonStrings.threeStringProperty,
4: NumberSuiteCommonStrings.fourStringProperty,
5: NumberSuiteCommonStrings.fiveStringProperty,
6: NumberSuiteCommonStrings.sixStringProperty,
7: NumberSuiteCommonStrings.sevenStringProperty,
8: NumberSuiteCommonStrings.eightStringProperty,
9: NumberSuiteCommonStrings.nineStringProperty,
10: NumberSuiteCommonStrings.tenStringProperty,
11: NumberSuiteCommonStrings.elevenStringProperty,
12: NumberSuiteCommonStrings.twelveStringProperty,
13: NumberSuiteCommonStrings.thirteenStringProperty,
14: NumberSuiteCommonStrings.fourteenStringProperty,
15: NumberSuiteCommonStrings.fifteenStringProperty,
16: NumberSuiteCommonStrings.sixteenStringProperty,
17: NumberSuiteCommonStrings.seventeenStringProperty,
18: NumberSuiteCommonStrings.eighteenStringProperty,
19: NumberSuiteCommonStrings.nineteenStringProperty,
20: NumberSuiteCommonStrings.twentyStringProperty
};

// RequireJS namespace, used for looking up translated strings
const NUMBER_SUITE_COMMON_REQUIREJS_NAMESPACE = 'NUMBER_SUITE_COMMON';

Expand Down Expand Up @@ -104,7 +105,7 @@ const NumberSuiteCommonConstants = {
numberToWord: ( numberPlaySecondaryStrings: SecondLocaleStrings, number: number, isPrimaryLocale: boolean ): string => {

// The word for number in the primary language
const primaryString = NUMBER_TO_STRING_KEY_PRIMARY[ number ].value;
const primaryString = NUMBER_TO_STRING_PROPERTY_PRIMARY[ number ].value;

// The word for number in the secondary language
const stringKey = `${NUMBER_SUITE_COMMON_REQUIREJS_NAMESPACE}/${NUMBER_TO_STRING_KEY_SECONDARY[ number ]}`;
Expand Down

0 comments on commit 1fbf1a7

Please sign in to comment.