From b945580ce9bf0a5a5a8c30cc6f98e09d65c385c6 Mon Sep 17 00:00:00 2001 From: Matthew Rajala Date: Tue, 15 Oct 2024 15:33:16 -0400 Subject: [PATCH] chore: change PLO get and set for Windows --- .../LocalizationService.cs | 43 +++++-------------- .../Uno.Extensions.Localization.WinUI.csproj | 2 + 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/Uno.Extensions.Localization.UI/LocalizationService.cs b/src/Uno.Extensions.Localization.UI/LocalizationService.cs index 105e6b7e15..38b1dd5c7a 100644 --- a/src/Uno.Extensions.Localization.UI/LocalizationService.cs +++ b/src/Uno.Extensions.Localization.UI/LocalizationService.cs @@ -59,46 +59,23 @@ defaultCulture is null ? } } - private static bool overrideSupported = -#if !__WINDOWS__ - true; -#else - PlatformHelper.IsAppPackaged; -#endif private string? PrimaryLanguageOverride { get { - if (!overrideSupported) - { - return default; - } - try - { - return ApplicationLanguages.PrimaryLanguageOverride; - } - catch (InvalidOperationException) - { - // This exception is raised on WinUI when unpackaged - overrideSupported = false; - return default; - } +#if WINDOWS + return Microsoft.Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride; +#else + return ApplicationLanguages.PrimaryLanguageOverride; +#endif } set { - if (!overrideSupported) - { - return; - } - try - { - ApplicationLanguages.PrimaryLanguageOverride = value; - } - catch (InvalidOperationException) - { - // This exception is raised on WinUI when unpackaged - overrideSupported = false; - } +#if WINDOWS + Microsoft.Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = value; +#else + ApplicationLanguages.PrimaryLanguageOverride = value; +#endif } } diff --git a/src/Uno.Extensions.Localization.UI/Uno.Extensions.Localization.WinUI.csproj b/src/Uno.Extensions.Localization.UI/Uno.Extensions.Localization.WinUI.csproj index 372a5f254b..dae37e000a 100644 --- a/src/Uno.Extensions.Localization.UI/Uno.Extensions.Localization.WinUI.csproj +++ b/src/Uno.Extensions.Localization.UI/Uno.Extensions.Localization.WinUI.csproj @@ -10,6 +10,8 @@ true Library + + 1.6.240923002