Skip to content

IPlatformSettings.PreferredApplicationLanguage API - #20108

Merged
MrJul merged 17 commits into
mainfrom
preferred-language-api
Aug 19, 2026
Merged

IPlatformSettings.PreferredApplicationLanguage API#20108
MrJul merged 17 commits into
mainfrom
preferred-language-api

Conversation

@maxkatz6

@maxkatz6 maxkatz6 commented Nov 20, 2025

Copy link
Copy Markdown
Member

What does the pull request do?

public interface IPlatformSettings
{
+        /// <summary>
+        /// Gets the preferred application language as specified in the operating system settings.
+        /// </summary>
+        string PreferredApplicationLanguage { get; }

+        /// <summary>
+        /// Raises when the preferred application language is changed in the operating system settings.
+        /// </summary>
+        event EventHandler? PreferredApplicationLanguageChanged;
}

Status

  • Default - fallbacks to CultureInfo.CurrentUICulture.Name, not sure if it's ideal
  • Windows - GetUserDefaultLocaleName
  • Browser - navigator.language
  • macOS
  • LANG/LC_MESSAGES could be used, but it's already respected by CultureInfo.InstalledUICulture
  • iOS
  • Android

Checklist

Fixed issues

Partially implements #19402

@maxkatz6 maxkatz6 added feature api-approved The new public APIs have been approved. labels Nov 20, 2025
@maxkatz6
maxkatz6 marked this pull request as ready for review August 18, 2026 13:10
…erredUILanguages doesn't work as expected with Windows settigns
@maxkatz6

Copy link
Copy Markdown
Member Author

@MrJul I resurrected this PR. So far tested on Windows, Android and Browser. Linux should be no-op. Will check iOS tomorrow.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068452-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Comment thread samples/ControlCatalog/ViewModels/PlatformSettingsViewModel.cs Outdated
Comment thread src/Avalonia.Base/Platform/IPlatformSettings.cs
Comment thread src/Avalonia.Base/Platform/DefaultPlatformSettings.cs
Comment thread src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs Outdated
Comment thread src/iOS/Avalonia.iOS/PlatformSettings.cs
@MrJul

MrJul commented Aug 18, 2026

Copy link
Copy Markdown
Member

Tested:

OS Getting language Change event
Windows ✅ OK ✅ OK
macOS ✅ OK ✅ OK
Browser ✅ OK ✅ OK
Android ✅ OK ⚠️ The application is automatically restarted
iOS ✅ OK ⚠️ The application is automatically restarted
Linux (KDE) ✅ OK ⚠️ A logoff/logon is required

So everything works as expected on all OSes, as the change callbacks are platform limitations.

# Conflicts:
#	src/Android/Avalonia.Android/Platform/AndroidPlatformSettings.cs
#	src/Avalonia.Native/NativePlatformSettings.cs
#	src/Browser/Avalonia.Browser/BrowserPlatformSettings.cs
#	src/Browser/Avalonia.Browser/BrowserTopLevelImpl.cs
#	src/Windows/Avalonia.Win32/Win32PlatformSettings.cs
#	src/iOS/Avalonia.iOS/PlatformSettings.cs
@maxkatz6
maxkatz6 force-pushed the preferred-language-api branch from 01dd3e1 to f2af57c Compare August 19, 2026 05:12
@maxkatz6
maxkatz6 requested a review from MrJul August 19, 2026 05:12
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068479-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrJul
MrJul enabled auto-merge August 19, 2026 06:38
@MrJul
MrJul added this pull request to the merge queue Aug 19, 2026
Merged via the queue into main with commit c01e1e1 Aug 19, 2026
10 checks passed
@MrJul
MrJul deleted the preferred-language-api branch August 19, 2026 08:51
@maxkatz6 maxkatz6 mentioned this pull request Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-approved The new public APIs have been approved. feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants