ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.53k stars 805 forks source link

Core strings are sometimes displayed in English instead of the user's preferred language #11104

Open n0samu opened 1 year ago

n0samu commented 1 year ago

When the user's locale does not exactly match the locale of the relevant translation, Ruffle defaults to US English for core text strings instead of using the most closely matching translation. For example, if the user's locale is ko, core strings are displayed in English because our Korean translation uses the ko-KR locale. Making matters worse is that on web, only the user's top preferred language is considered (navigator.language), when we should be considering all preferred languages (navigator.languages). For most Korean users, the navigator.language value seems to be ko.

You can see the problem for yourself by following these steps:

  1. Install the Locale Switcher extension in your browser.
  2. Load the Ruffle Web Demo.
  3. Activate Locale Switcher and select Korean (ko).
  4. Right-click within the Ruffle player. image

When "Korean (South Korea)" (ko-KR) is selected instead, the context menu appears as expected: image

To fix this problem we need to:

  1. Use navigator.languages instead of navigator.language
  2. Change ui.language to ui.languages (make it a vec type)
  3. Use fluent-langneg to negotiate between the user's preferred languages and Ruffle's available translations
  4. Make the core_text and core_text_with_args functions take a vec of languages
Dinnerbone commented 1 year ago

Opened https://github.com/1Password/sys-locale/pull/22 for part of this