-
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
Locale Query Parameter taking long values like "espan" and loading like it is "es" #963
Comments
We also observed, e.g., that https://phet.colorado.edu/sims/html/center-and-variability/latest/center-and-variability_all.html?locale=swedish comes up Swahili. |
Would we want it to pop up the "invalid query parameter" dialog, if that exists? |
These bits of code look relevant. This bug seems related to a desired to (for example) default 'zh_CN' => 'zh'. But it's buggy because there's no checking for the locale format and where the '_' appears. localeProperty.ts: // We might use a partial locale (e.g. 'en' instead of 'en_US'), so grab this if it exists. It might be the same as
// phet.chipper.locale (that's OK).
const partialLocale = typeof phet.chipper.locale === 'string' ? phet.chipper.locale.slice( 0, 2 ) : undefined; localeOrderProperty.ts // Attempt to fill in a language reduction for the selected locale, e.g. 'zh_CN' => 'zh'
const shortLocale = locale.slice( 0, 2 ) as Locale;
if ( locale !== shortLocale && !localeOrder.includes( shortLocale ) ) {
localeOrder.push( shortLocale );
} |
@jonathanolson - I believe, yes, we would want it to pop up that invalid query parameter note if its not a valid value at all: But please chime in agreement or with another thought @pixelzoom @zepumph @arouinfar from today's discussion. So the "PhET brand" would pop up the not a valid option note. |
We are in control with what we consider to be the schema of a locale string, so potentially the solution is as easy as adding
I thought that we don't want this since we have started using Looks like some paper trail is in #905, where the note about NOT adding
That's correct, it will take the value from the state. If by "fail out" you mean assert in the wrapper frame (which won't error unless we have |
JO and I talked through this ?locale behavior re when to and when not to pop up an error message in PhET Brand. Here is the suggested behavior: If any supported format is entered "xx_XX", or "xx", or "xxx" (i would say we should be lenient and make these all case insensitive, @jonathanolson):
-NOTE: this is a small bit different from the "within-sim" fallback where one string is missing a locale. If something else is entered "espanol" or "swedish" or "12345":
Does this sound like the best combo of actions to all? (@arouinfar noted in slack that "Sounds reasonable to me!" |
There are standards for locale fallback, most notably the ICU standard. PhET doesn't use the full ICU locale format (only language and country codes) but the fallback order you've described is consistent with that standard. See also https://learn.microsoft.com/en-us/globalization/locale/fallback. |
It's good to have @mattpen 's website fallback issue tagged here. https://github.com/phetsims/website-meteor/issues/673 |
Working copy snapshot in https://gist.github.com/jonathanolson/13813e2481f5e3bc860ab4e4f871c39a (changeset too large for a github comment), DO NOT COMMIT. |
…eData, and initial switches to use it in simulations and simulation builds, see phetsims/joist#963
…eData, and initial switches to use it in simulations and simulation builds, see phetsims/joist#963
…eData, and initial switches to use it in simulations and simulation builds, see #963
…eData, and initial switches to use it in simulations and simulation builds, see phetsims/joist#963
…ings, and locales get resorted due to localizedName alphabetization changes), see phetsims/joist#963
…eData, and initial switches to use it in simulations and simulation builds, see phetsims/joist#963
… tree (and the new fallback). Adjusting unbuilt loading, so we load localeData BEFORE loading translations. see phetsims/joist#963
… tree (and the new fallback). Adjusting unbuilt loading, so we load localeData BEFORE loading translations. see phetsims/joist#963
I'll add the migration rule for acid-base-solutions |
OK I fixed acid-base-solutions. CT says we need to do the same for keplers-laws, projectile-data-lab, and projectile-sampling-distributions. |
Tagging code review issue: phetsims/chipper#1441 |
MR is complete and published. Next steps on main in phetsims/chipper#1441. |
Noting that the final feature we landed on here is documented in phetsims/qa#1089 (comment). |
Reopening because there is a TODO marked for this issue. |
Signed-off-by: Michael Kauzmann <[email protected]>
Signed-off-by: Michael Kauzmann <[email protected]>
I moved three TODOs over to phetsims/chipper#1441. |
Today, we discovered that on PhET Brand, the locale query parameter is doing something somewhat un-expected:
If you type in https://phet.colorado.edu/sims/html/center-and-variability/latest/center-and-variability_all.html?locale=esnas
the sim will load in "es" spanish.
It seems like with this value, it should fall back to "en" because esnas is not a valid value for the locale query parameter.
@jonathanolson - It seems like this is code that you might be working on with the locale improvements you are doing right now. Is that true?
The text was updated successfully, but these errors were encountered: