#1305 UI language: System default follows the Windows display language; restart notice on OK #1339

Merged
sky_line merged 3 commits from TheSlowly/Slipstream:ui-language-1305 into main 2026-10-31 22:09:14 +00:00
Collaborator

Fixes #1305 as far as the code goes; the ticket asks the reporter for their settings to confirm which cause it was. An explicit language already wins everywhere, so these are the likely causes:

  • System default on Windows followed the regional format (GetThreadLocale) rather than the display language. It now uses GetUserDefaultUILanguage.
  • The restart notice appeared as soon as a language was picked, even though Cancel or X then discarded the choice. It now comes with OK.
  • One resolver: a few places read the raw Language setting (ja/pl month names, the abuse-report categories, the UI preview tool). They now go through one resolver, SLUILanguage::resolve, which has a unit test.

Tested in-world: picking a language, Cancel and OK. System default on a Windows whose display and regional languages differ wasn't available to test.

Fixes #1305 as far as the code goes; the ticket asks the reporter for their settings to confirm which cause it was. An explicit language already wins everywhere, so these are the likely causes: - **System default** on Windows followed the regional format (`GetThreadLocale`) rather than the display language. It now uses `GetUserDefaultUILanguage`. - **The restart notice** appeared as soon as a language was picked, even though Cancel or X then discarded the choice. It now comes with OK. - **One resolver:** a few places read the raw `Language` setting (ja/pl month names, the abuse-report categories, the UI preview tool). They now go through one resolver, `SLUILanguage::resolve`, which has a unit test. Tested in-world: picking a language, Cancel and OK. System default on a Windows whose display and regional languages differ wasn't available to test.
With Preferences > Language on "System default", the viewer resolves its language from
SystemLanguage, which on Windows came from FL_FindLocale() reading GetThreadLocale(). The
thread locale is the user's regional format (Settings > Time & language > Region), not the
language Windows displays. An English Windows with German date and number formats therefore
got a German viewer, and a German Windows with English formats an English one.

FL_FindLocale(FL_MESSAGES) now reads GetUserDefaultUILanguage(), the display language. The
LCID-to-code table is unchanged, so the codes are the same ("de", "fr", "zh", ...), and a
display language the table does not know still falls back to "en". An explicitly chosen
language is untouched (it already wins over SystemLanguage), and Linux keeps reading
LC_ALL / LC_MESSAGES / LANG / LANGUAGE.

Test-Plan: On Windows with the display language English and the regional format German
  (Settings > Time & language > Language & region: Windows display language English,
  Regional format German), set Preferences > Language to System default and restart: the
  viewer is in English, and the log's AppInit "Language:" line says en. With the display
  language German (any regional format) and System default, the viewer is in German.
  With an explicit language chosen (e.g. English on a German Windows), that language is
  used whatever the display language or format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picking a language in Preferences > General showed "Changing language will take effect
after you restart" at once. That reads as if the choice were already saved, but the combo
only changes the live setting: Cancel, or closing Preferences with the X, puts the old
value back (LLFloaterPreference::onClose -> cancel()). A user who picked English, dismissed
the notice and closed the window came back after a restart to the same translated viewer.

The notice now appears when OK saves a language that differs from the one the floater
opened with, and only if that choice resolves to a language other than the one this
session's UI is in (going back to the current language, or between System default and the
language it resolves to, needs no restart). Picking a language shows nothing; Cancel and
the X still discard it.

Test-Plan: Open Preferences > General, pick another language: no notice. Close with Cancel
  (or the X) and restart: the language is unchanged. Pick the language again and press OK:
  the "take effect after you restart" notice appears; restart and the UI is in that
  language. Reopen, press OK without touching the language: no notice. Pick the language
  the viewer is running in (or System default when it resolves to it) and press OK: no
  notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rule that turns the settings into the UI language (Language, else InstallLanguage, else
SystemLanguage, else "en") lived only in LLUI::getUILanguage(). Code that ran before LLUI
existed, or read gSavedSettings "Language" directly, saw the literal "default" whenever
Preferences > Language is System default, so those places did not follow the language the
rest of the UI uses:
- the Japanese / Polish weekday and month names (LLAppViewer::init) were only set up for an
  explicit ja / pl, so System default on a Japanese or Polish system got the broken
  strftime names they exist to replace;
- the abuse report categories were requested without a language for System default and
  came back in English in an otherwise translated report floater;
- the skin search path set in initConfiguration(), before LLUI exists, used "default" as
  the language folder;
- the XUI preview tool restored the search path with the raw setting after a preview, so a
  System default session built every later floater from the English files only.

SLUILanguage::resolve() (new, llui) now holds the rule, with a unit test. LLUI::getUILanguage()
and initConfiguration() call it, and the other places use LLUI::getLanguage(). An explicit
language resolves to itself, so nothing changes for it.

Test-Plan: On a Japanese (or Polish) Windows display language with Preferences > Language on
  System default: the weekday in the status bar clock's date tooltip and in the Inspect
  floater / About Land times is the localized name, as with Japanese chosen explicitly.
  On a German Windows with System default, open Report Abuse in-world: the category list
  is German. With English chosen explicitly on that system both stay English.
  Unit test: tests/sluilanguage_test.cpp (4 groups pass).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream!1339
No description provided.