Skip to content

Commit

Permalink
initial commit getting Fluent.js working in GFL:B, see phetsims/joist…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Nov 22, 2024
1 parent 208231d commit 4833da8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gravity-force-lab-basics-strings_en.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distance-arrow-visible = Distance measured in kilometers.
distance-arrow-removed = Distance measurement hidden.
8 changes: 7 additions & 1 deletion gravity-force-lab-basics_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
"phet-io",
"adapted-from-phet"
],
"preload": [
"../sherpa/lib/fluent-0.13.0.min.js",
"../chipper/js/load-unbuilt-fluent-strings.js"
],
"simFeatures": {
"supportsInteractiveDescription": true,
"supportsVoicing": true,
Expand Down Expand Up @@ -116,7 +120,9 @@
'../sherpa/lib/seedrandom-2.4.2.js',
'../sherpa/lib/base64-js-1.2.0.js',
'../sherpa/lib/TextEncoderLite-3c9f6f0.js',
'../tandem/js/PhetioIDUtils.js'
'../tandem/js/PhetioIDUtils.js',
'../sherpa/lib/fluent-0.13.0.min.js',
'../chipper/js/load-unbuilt-fluent-strings.js'
];

if ( brand === 'phet-io' ) {
Expand Down
25 changes: 25 additions & 0 deletions js/GravityForceLabBasicsFluentMessages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2024, University of Colorado Boulder

/**
* Prototype for preparing fluent strings for Gravity Force Lab: Basics. Fluent strings are loaded in a preload script.
* They are then processed into Properties so that they can be used in the simulation.
*
* See Classes in Chipper that support Fluent:
* - https://github.com/phetsims/joist/issues/992
* - https://github.com/phetsims/chipper/issues/1532
*
* @author Jesse Greenberg (PhET Interactive Simulations)
*/

import { englishBundle } from '../../chipper/js/localizedFluentBundleProperty.js';
import FluentUtils from '../../chipper/js/FluentUtils.js';
import LocalizedMessageProperty from '../../chipper/js/LocalizedMessageProperty.js';

const GravityForceLabBasicsFluentMessages = {};
for ( const [ id ] of englishBundle.messages ) {

// So that you can look up fluent strings with camelCase.
GravityForceLabBasicsFluentMessages[ FluentUtils.fluentIdToMessageKey( id ) ] = new LocalizedMessageProperty( id );
}

export default GravityForceLabBasicsFluentMessages;
5 changes: 3 additions & 2 deletions js/view/GFLBAlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import GravityForceLabAlertManager from '../../../gravity-force-lab/js/view/Grav
import merge from '../../../phet-core/js/merge.js';
import ActivationUtterance from '../../../utterance-queue/js/ActivationUtterance.js';
import gravityForceLabBasics from '../gravityForceLabBasics.js';
import GravityForceLabBasicsFluentMessages from '../GravityForceLabBasicsFluentMessages.js';
import GravityForceLabBasicsStrings from '../GravityForceLabBasicsStrings.js';

const distanceArrowVisibleString = GravityForceLabBasicsStrings.a11y.distanceArrowVisible;
const distanceArrowRemovedString = GravityForceLabBasicsStrings.a11y.distanceArrowRemoved;
const distanceArrowVisibleString = GravityForceLabBasicsFluentMessages.distanceArrowVisibleMessageProperty;
const distanceArrowRemovedString = GravityForceLabBasicsFluentMessages.distanceArrowRemovedMessageProperty;

class GFLBAlertManager extends GravityForceLabAlertManager {

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"phet-io",
"adapted-from-phet"
],
"preload": [
"../sherpa/lib/fluent-0.13.0.min.js",
"../chipper/js/load-unbuilt-fluent-strings.js"
],
"simFeatures": {
"supportsInteractiveDescription": true,
"supportsVoicing": true,
Expand Down

0 comments on commit 4833da8

Please sign in to comment.