Skip to content

Add support for dynamic strings to content of "Word" accordion box #199

Description

@pixelzoom

The content of the "Word" accordion box does not currently support dynamic strings. So if you run the sim with ?stringTest=dynamic and use the left/right arrow keys, you will not see any change to the contents of the accordion box.

The main reason for this is that we do not have string Properties for the secondary locale. Instead we have this Property in NumberSuiteCommonPreferences.ts, whose value is an object literal consisting of keys and static strings:

  public readonly secondLocaleStringsProperty: TReadOnlyProperty<IntentionalAny>;

And in WordAccordionBox.ts, we call NumberSuiteCommonConstants.numberToString to map an integer number to the word for that integer:

    // The word shown in the accordion box
    const wordStringProperty = new DerivedProperty(
      [ currentNumberProperty, isPrimaryLocaleProperty, numberPlayPreferences.secondLocaleStringsProperty ],
      ( currentNumber, isPrimaryLocale, secondLocaleStrings ) =>
        NumberSuiteCommonConstants.numberToString( secondLocaleStrings, currentNumber, isPrimaryLocale )
    );

    const wordText = new Text( wordStringProperty, {
      font: options.font,
      maxWidth: this.contentBoundsProperty.value.width - options.textOffsetX - TEXT_MARGIN
    } );

What really needs to happen is something like:

    const wordText = new Text( '', {
      font: options.font,
      maxWidth: this.contentBoundsProperty.value.width - options.textOffsetX - TEXT_MARGIN
    } );

    Multilink.multilink(
      [ currentNumberProperty, isPrimaryLocaleProperty, numberPlayPreferences.secondLocaleStringsProperty ],
      ( currentNumber, isPrimaryLocale, secondLocaleStrings ) => {
        wordText.stringProperty = NumberSuiteCommonConstants.numberToStringProperty( secondLocaleStrings, currentNumber, isPrimaryLocale );
   } ); 

... where NumberSuiteCommonConstants.numberToStringProperty does not currently exist.

PhET-iO is not included for the 1.0 release, and the only way to change string Properties is via PhET-iO/Studio. So we decided to leave this as a known problem for the 1.0 release, and label this issue as deferred.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions