-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Fluent.js for complex accessibility strings #992
Comments
The latest version of Fluent.js was not compatible with our preload system/sherpa which requires a standalone built file. We found a build in this format at https://www.npmjs.com/package/fluent. It is 5 years old. We will want to figure out how we can get the latest version. For other POSE reasons, PhET is exploring how we can use a more standard way of importing dependencies. But if that isn't figured out, we will need to find a way to bundle a more recent version of Fluent so it can be used in sherpa. |
The above commits complete a first pass at using Fluent in ohms-law for accessibility strings. |
This reverts commit de7987b.
I am making a branch in chipper called fluent to hold preloads and utility classes that are supporting this work. See #1532. |
…d in multiple sim prototypes, see phetsims/joist#992 and #1532
GFL:B is proving to be too time consuming for this test because of the complicated string patterns. Strings are factored out and reassembled with code in a way that is good for English but is not friendly for i18n. We are going to switch to MaL instead. |
List of repo branches so far to support this work:
|
…see phetsims/joist#992 and #416" This reverts commit a0f3d4a.
The above commits complete a first pass at using Fluent in molecules-and-light for accessibility strings. |
I met with @jonathanolson today to discuss Fluent.js support. We looked into the limitation described in #986 (comment) (attribute references cannot use variables which can create significant complexity in the Fluent.js patterns). We couldn't find a solution. We thought this was important because of the following simple example string. All of this code (113 lines!!) is needed to translate the sentence "There are {{5}} {{yellow}} {{dogs}}" (brackets indicate a variable). -dog = perro -red-masculine = rojo -black-masculine = negro -white-masculine = blanco lang-noun = { $noun -> noun-article = { $noun -> -term = { $first -> color = { $noun -> sentence = { $quantity -> Consider the equivalent 6 lines of javascript: const singular = quantity === 1;
const masculine = [ 'dog' ].includes( noun );
const nounString = { dog: 'perro', house: 'casa', table: 'mesa', street: 'calle' }[ noun ] + ( singular ? '' : 's' );
const colorString = { red: 'roj', black: 'negr', white: 'blanc', yellow: 'amarill' }[ color ] + ( masculine ? 'o' : 'a' ) + ( singular ? '' : 's' );
const string = `${singular ? 'Es' : 'Son'} ${singular ? (masculine ? 'un' : 'una') : quantity} ${nounString}` We looked into a custom functions (a Fluent.js feature) to improve this. We hoped this would be something that a translator to directly get translations for variable terms and attributes. You can create your own function in a Fluent bundle like this: function CALL( ...args: any ) {
// Do something with the provided term and its attributes to select the appropriate translations.
// For example, look up a .gender attribute on the provided term and then return a string that
// combines
console.log( args );
return 'a string';
};
const bundle = new FluentRef.FluentBundle( locale, {
functions: {
CALL: CALL
}
} ); And the translator could use it like this: -dog = perro
.gender = masculine
-cat = gata
.gender = feminine
-color-white =
{ $case ->
*[feminine] blanca
[masculine] blanco
}
dog-description = The { $animal ->
[DOG] { -dog}
[CAT] { -cat }
} is { CALL($animal, color: -color-white) } Unfortunately, the values passed to the custom function (like the value of We talked about possibilities like
It is not clear how important this is. We haven't encountered this amount of complexity in the sims we have worked on so far (ohms-law, molecules-and-light, ph-scale-basics). |
After #990, we are going to try Fluent.js to support i18n for complex accessibility strings.
In this issue Ill track changes and progress. First, we are going to bring Fluent in as a dependency. Then, we are going to try it out with 3 sims. We are then going to test the strings with translators to get feedback.
EDIT: I have a growing list of branches in repos as we do this work. Collected in this coment: #992 (comment)
The text was updated successfully, but these errors were encountered: