Skip to content

refactor(globalization)!: Remove UseLegacyPrimaryLanguageOverride (BC50) - #23905

Open
Xiaoy312 wants to merge 2 commits into
feature/breakingchangesfrom
dev/xygu/20260728/bc50-remove-uselegacyprimarylanguageoverride
Open

refactor(globalization)!: Remove UseLegacyPrimaryLanguageOverride (BC50)#23905
Xiaoy312 wants to merge 2 commits into
feature/breakingchangesfrom
dev/xygu/20260728/bc50-remove-uselegacyprimarylanguageoverride

Conversation

@Xiaoy312

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #13704

PR Type:

💬 Other... Breaking change (behaviour alignment with WinUI)

What changed? 🚀

Hard-removes the Uno-only WinRTFeatureConfiguration.ApplicationLanguages.UseLegacyPrimaryLanguageOverride flag and, with it, the legacy immediate-culture-apply path (BC50 of the Phase 5 breaking-changes wave).

Before: the flag defaulted to true, so setting Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride swapped CultureInfo.CurrentCulture / CurrentUICulture / DefaultThreadCurrent* from inside the setter — a mid-session culture change with no WinUI counterpart.

After: the setter no longer touches the culture. The override is still persisted to local settings and still updates ApplicationLanguages.Languages immediately, and Application's constructor still calls ApplyCulture() at startup — so the net behaviour is WinUI's restart-to-apply.

Resource lookup is unaffected: ResourceLoader reads PrimaryLanguageOverride directly (via the separate, unchanged WinRTFeatureConfiguration.ResourceLoader.UsePrimaryLanguageOverride), so x:Uid / GetString keep following the new value immediately. Localized strings still hot-swap on page reload; only the formatting culture waits for the restart.

  • ApplicationLanguages.PrimaryLanguageOverride — dropped the flag-gated ApplyCulture() call.
  • WinRTFeatureConfiguration — deleted the flag and the now-empty ApplicationLanguages holder (no [Obsolete] shim, per the recorded decision).
  • PackageDiffIgnore.xml — 4 entries under <IgnoreSet baseVersion="6.6">: the removed holder type, the property form, and the get_/set_ accessors. (The 6.5 set is retired — an in-file comment notes its entries were relocated to 6.6 when the diff base advanced to 6.6.166, since generatepkgdiff consults only the set matching the base major.minor.)
  • Docs — migration note in migrating-to-uno-7.md, plus a note in the "change app language at runtime" guide, which documents exactly this scenario.

Validation

  • Runtime (fails-before / passes-after): new Given_ApplicationLanguages.When_PrimaryLanguageOverride_Then_Culture_Unchangedfailed before the source change (CurrentCulture became fr-CA, expected en-US) and passes after. It picks its target language relative to the ambient culture so it cannot pass by coincidence, and restores all four CultureInfo statics in a finally.
  • Runtime (regression), Skia Desktop net10.0: Given_ApplicationLanguages 3/3, Given_ResourceLoader 18/18 (confirms resource resolution still follows the override immediately), Given_DatePicker 12/12.
  • Compile: Uno.UWP (Skia net10.0) full rebuild with UnoFastDevBuild=false — analyzers on, 0 warnings / 0 errors. SamplesApp.Skia.Generic clean.
  • Pre-existing failures, verified unrelated — identical results with src/Uno.UWP/ reverted and rebuilt: When_Calendar 13 failures in Uno.UI.UnitTests (3997 pass), DatePickerIntegrationTests 2 failures.
  • Native Android/iOS heads were not built locally — CI validates them. The removed flag had no callers anywhere in the repo outside the setter it gated.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — Given_ApplicationLanguages.When_PrimaryLanguageOverride_Then_Culture_Unchanged, fails-before / passes-after.
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — migration note in migrating-to-uno-7.md and in guides/hotswap-app-language.md.
  • 🖼️ Validated PR Screenshots Compare Test Run results — N/A (no visual change).
  • ❗ Contains NO breaking changes — intentionally left unchecked; this is a breaking change (see below).
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

Breaking change — impact & migration path

Unlike most flag removals in this wave, this flag defaulted to true, so it changes behaviour for apps that never touched it.

  • Impact (behavioural + source-breaking): apps that switched UI language at runtime by setting PrimaryLanguageOverride and relied on CultureInfo.CurrentCulture following immediately lose that side effect — number, date, and currency formatting (and .NET resource lookup through CurrentUICulture) keep the previous culture until the next app start. Code that read or set the flag no longer compiles, and there is no opt-back-in: the legacy path is gone.

  • Migration: set the culture explicitly alongside the override:

    ApplicationLanguages.PrimaryLanguageOverride = language;
    
    var culture = new CultureInfo(language);
    CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = culture;
    CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = culture;

    Apps that already restart — or re-navigate — on language change need no change: localized strings still update through ResourceLoader.

@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure kind/documentation labels Jul 29, 2026
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23905/wasm-skia-net9/index.html

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 224734 found UI Test snapshots differences: skia-linux-screenshots: 88, skia-windows-screenshots: 91

Details
  • skia-linux-screenshots: 88 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • ColorPickerSample.png
    • ImageSourceUrlMsAppDataScheme.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Buttons.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DropDownButtonPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • Image_UseTargetSizeLate.png-dark
    • Image_UseTargetSizeLate.png
  • skia-windows-screenshots: 91 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • DynamicFont.png
    • Image_UseTargetSize.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Buttons.png-dark
    • ClipboardTests.png-dark
    • Buttons.png
    • ClipboardTests.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • FluentStyle_NavigationViewSample.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 224734 has failed on Uno.UI - CI.

Xiaoy312 and others added 2 commits July 29, 2026 16:11
WinRTFeatureConfiguration.ApplicationLanguages.UseLegacyPrimaryLanguageOverride
gated a Uno-only extra ApplyCulture() call inside the PrimaryLanguageOverride
setter, so setting the override swapped CultureInfo.CurrentCulture mid-session.
WinUI applies the override to the culture only on the next app start.

Hard-remove it (no [Obsolete] shim) and behave as if it were false:
- ApplicationLanguages: drop the gated ApplyCulture() from the setter. The
  override is still persisted and still updates Languages immediately, and
  Application's constructor still applies the culture at startup, so the
  behaviour is WinUI's restart-to-apply.
- WinRTFeatureConfiguration: delete the now-empty ApplicationLanguages holder.
- PackageDiffIgnore (6.6): ignore the removed holder plus the flag property and
  its get/set accessors.
- Given_ApplicationLanguages: fails-before/passes-after guard asserting the
  culture is untouched while Languages[0] follows the override.
- migrating-to-uno-7.md: migration note. The flag defaulted to true, so unlike
  the other removed flags this changes behaviour for apps that never touched it;
  the note gives them the explicit CultureInfo assignment to use instead.

Resource lookup (x:Uid, ResourceLoader) reads PrimaryLanguageOverride directly,
so localized strings keep updating without a restart.

BC50 of the 7.0 breaking-changes rollup (#8339), for #13704.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The runtime language-switch guide sets PrimaryLanguageOverride and relies on
re-navigation to refresh localized strings, which still works. Call out that the
culture itself now follows on the next app start (BC50), and give the explicit
CultureInfo assignment for apps that need formatting to switch in-session.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Xiaoy312
Xiaoy312 force-pushed the dev/xygu/20260728/bc50-remove-uselegacyprimarylanguageoverride branch from 971aa1c to c1de3f8 Compare July 29, 2026 20:12
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23905/wasm-skia-net9/index.html

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 224861 found UI Test snapshots differences: skia-linux-screenshots: 88, skia-windows-screenshots: 90

Details
  • skia-linux-screenshots: 88 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ColorPickerSample.png
    • DropDownButtonPage.png-dark
    • DataTransferManager.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Image_Margin_Large.png-dark
    • Image_UseTargetSizeLate.png-dark
    • Image_UseTargetSizeLate.png
    • Buttons.png-dark
    • Buttons.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • DoubleImageBrushInList.png-dark
  • skia-windows-screenshots: 90 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Gamepad_Enumeration.png-dark
    • Buttons.png-dark
    • Buttons.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Gamepad_CurrentReading.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Image_UseTargetSize.png-dark
    • AppBar_KeyBoard.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 224861 has failed on Uno.UI - CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants