phetsims / joist

Joist is the main framework for PhET Interactive Simulations. Joist creates and displays the simulation content, home screen, navigation bar, About dialog, enables switching between tabs, and other framework-related features.
MIT License
8 stars 6 forks source link

Locales are not presented in alphabetical order. #911

Open pixelzoom opened 1 year ago

pixelzoom commented 1 year ago

On the Localization tab of the Preferences dialog, the locales are not in alphabetical order. See screenshot below. It looks like they are ordered by locale code (which is not displayed) instead of by Locale.name or Locale.localizedName. It's not clear which of those should determine the ordering, but ordering them by locale code seems buggy.

screenshot_2326
chrisklus commented 1 year ago

In design meeting with @jessegreenberg @amanda-phet @catherinecarter and @samreid:

We considered three different ways of sorting: by locale code (current), by english name, and by localized name. We decided that sorting by localizedName made the most sense because it seemed the least biased towards devs and the english language.

@samreid also asked ChatGPT and it said that sorting by localized name makes sense because sort functions use unicode placement after alphabetical, so this should be close to the universal way of sorting them.

chrisklus commented 1 year ago

Committed above. Here is the new order:

image

amanda-phet commented 1 year ago

@samreid can you paste in the reference for why this is a reasonable sort?

samreid commented 1 year ago

I asked:

How would you sort this list? عربي, English, 中国人 ?

ChatGPT replied:

To sort the list ["عربي", "English", "中国人"] correctly, you would need to use a sorting method that takes into account the different character sets used by each language. In this case, you could sort the list using Unicode collation order, which is an internationally recognized standard for sorting multilingual text.

and provided a code example of how to implement it.

jessegreenberg commented 1 year ago

Thanks for committing https://github.com/phetsims/joist/commit/53c86e0e6b604cee615da2f5d4c5b95d10fda79c @chrisklus! Are there any next steps for this issue? Do we need any other tests to make sure it is OK to sort availableRuntimeLocales instead of doing that view side?

zepumph commented 1 year ago

RE: https://github.com/phetsims/joist/commit/53c86e0e6b604cee615da2f5d4c5b95d10fda79c

This changed the PhET-iO API and required stable API validation. Now the localeProperty validValues is a different order.