Fix #191: switching back to English restores every page #192

Manually merged
github merged 1 commit from github-bot/gh-192 into main 2026-12-04 18:12:52 +00:00 AGit
Owner

@⁠laalaalaee on GitHub · 2026-12-04 12:12 UTC · original
laalaalaee:fix/language-switch-back → main · +6 −2 · 1 files · 1 commits · merged 2026-12-04 18:08 UTC

Fixes #191.

Problem

After switching the language to e.g. Polish and back to English, only the sidebar returns to English; every page after it (Darner, FoxHound, Save, Mods, Settings, ...) keeps the previous language, and the sidebar's "Questions & Requests?" link can keep a language from an earlier switch.

Cause

Localizer.Walk enumerated LogicalTreeHelper.GetChildren() while translating the children. Setting a Run's text (the sidebar's "Questions & Requests? / Click here" link) changes the inline collection being enumerated, so the walk threw InvalidOperationException: Collection was modified (from RangeContentEnumerator.MoveNext) and the catch in Apply ended it there. While a translation is on, the 300 ms timer repeats the walk and each pass gets a little further, which hid it; switching back to English runs one pass and stops the timer.

Change

Only Services/Localizer.cs (+6/−2):

  • The logical children are copied to an array before they are walked.
  • Handle is wrapped per control, so one control that fails to translate no longer ends the walk for the rest of the window (Apply keeps its outer catch).

Testing

  • dotnet build -c Release passes (0 errors, no new warnings).
  • In the running launcher (FoxHound page open) I switched languages from code and compared every TextBlock / Run / ContentControl text with the starting English state:
    • Before: Collection was modified on every pass; after Polish -> English about 250 texts stayed in Polish.
    • After: no exception; Polish -> English, Portuguese -> Polish -> English, and Russian -> Spanish -> French -> Turkish -> Chinese -> Italian -> English all leave no translated text behind.
    • Polish alone now translates all 257 texts in the first pass instead of over several timer passes.
**@⁠laalaalaee** on GitHub · 2026-12-04 12:12 UTC · [original](https://github.com/isaac-btw/AmericasLauncher/pull/192) `laalaalaee:fix/language-switch-back` → `main` · +6 −2 · 1 files · 1 commits · merged 2026-12-04 18:08 UTC Fixes #191. ### Problem After switching the language to e.g. Polish and back to English, only the sidebar returns to English; every page after it (Darner, FoxHound, Save, Mods, Settings, ...) keeps the previous language, and the sidebar's "Questions & Requests?" link can keep a language from an earlier switch. ### Cause `Localizer.Walk` enumerated `LogicalTreeHelper.GetChildren()` while translating the children. Setting a `Run`'s text (the sidebar's "Questions & Requests? / Click here" link) changes the inline collection being enumerated, so the walk threw `InvalidOperationException: Collection was modified` (from `RangeContentEnumerator.MoveNext`) and the `catch` in `Apply` ended it there. While a translation is on, the 300 ms timer repeats the walk and each pass gets a little further, which hid it; switching back to English runs one pass and stops the timer. ### Change Only `Services/Localizer.cs` (+6/−2): - The logical children are copied to an array before they are walked. - `Handle` is wrapped per control, so one control that fails to translate no longer ends the walk for the rest of the window (`Apply` keeps its outer catch). ### Testing - `dotnet build -c Release` passes (0 errors, no new warnings). - In the running launcher (FoxHound page open) I switched languages from code and compared every TextBlock / Run / ContentControl text with the starting English state: - Before: `Collection was modified` on every pass; after Polish -> English about 250 texts stayed in Polish. - After: no exception; Polish -> English, Portuguese -> Polish -> English, and Russian -> Spanish -> French -> Turkish -> Chinese -> Italian -> English all leave no translated text behind. - Polish alone now translates all 257 texts in the first pass instead of over several timer passes.
Localizer.Walk enumerated LogicalTreeHelper.GetChildren() while translating
the children. Setting a Run's text (the sidebar's "Questions & Requests?" /
"Click here" link) changes the inline collection being enumerated, so the
walk threw "Collection was modified" there and the catch in Apply ended it.

While a translation is on, the 300 ms timer repeats the walk and each pass
got a little further, which hid it. Switching back to English runs one pass
and stops the timer, so every page after the sidebar (Darner, FoxHound,
Settings, ...) kept the old language, and the sidebar link could keep a
third language from an earlier switch.

The children are now copied before they are walked, and a control that
fails to translate no longer ends the walk for the rest of the window.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 12:14:29 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-12-04 12:12 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-12-04 12:12 UTC · [original](https://github.com/isaac-btw/AmericasLauncher/pull/192#pullrequestreview-6188690456) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠C1berCanarri on GitHub · 2026-12-04 16:19 UTC · original · approved these changes

**@⁠C1berCanarri** on GitHub · 2026-12-04 16:19 UTC · [original](https://github.com/isaac-btw/AmericasLauncher/pull/192#pullrequestreview-6192517954) · **approved these changes**
github manually merged commit 9354824c32 into main 2026-12-04 18:12:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.