Skip to content

Follow the language the OS prefers for apps - #200

Merged
vesnicancz merged 1 commit into
masterfrom
follow-preferred-app-language
Nov 26, 2026
Merged

vesnicancz merged 1 commit into
masterfrom
follow-preferred-app-language

Conversation

@vesnicancz

Copy link
Copy Markdown
Owner

The "System" language option resolved to CultureInfo.CurrentUICulture. Avalonia 12.2 adds IPlatformSettings.PreferredApplicationLanguage, so the app now takes that and keeps the .NET UI culture as the fallback.

  • Windows: Avalonia reads the first entry of GlobalizationPreferences.Languages, which follows the Windows 11 preferred languages list (its own comment says GetUserPreferredUILanguages does not).
  • macOS: the native preferred language.
  • Linux: Avalonia does not override it and returns CultureInfo.InstalledUICulture, so in practice nothing changes there.

LanguageCatalog.ResolveSystemCulture turns the tag into a culture and falls back on an empty or unknown tag. LocalizationService takes the system culture in its constructor, so tests no longer depend on what the headless platform reports.

The resolved culture also becomes CurrentCulture (as before), so if the OS reports a neutral tag such as cs, date and number formats come from the neutral culture rather than cs-CZ. The language is read once at startup; a change in the OS applies after a restart, as before.

Build and all 1554 tests pass locally. Not tried on a real Windows 11 or macOS machine with differing language settings.

The "system" language option took CultureInfo.CurrentUICulture. Avalonia 12.2
reports the language the operating system prefers for applications, which on
Windows comes from the Windows 11 preferred languages list and on macOS from
the native preferred language, so use it and keep the .NET UI culture as the
fallback when the platform reports nothing or an unknown tag.

LocalizationService now takes the system culture in its constructor, so tests
don't depend on what the headless platform reports.
@vesnicancz
vesnicancz merged commit 4380ceb into master Nov 26, 2026
9 of 11 checks passed
@vesnicancz
vesnicancz deleted the follow-preferred-app-language branch November 26, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant