Fix macOS native menu bar reverting to English after restart (#11505)#11508
Merged
Conversation
The macOS NSMenuBar is built in Program.Main (right after SetupMainWindow) and InitNativeMacMenu.MakeStructure reads Se.Language directly. But the UI translation was loaded inside MainView.Build(), which runs lazily on attach during lifetime.Start() — after the native menu is already constructed. So on restart the menu bar was built from the default English strings even though the rest of the UI localized correctly. (Runtime language changes were unaffected because they call InitNativeMacMenu.Rebuild.) - Add Se.LoadLanguage(): loads the configured translation into Se.Language - Call it in Program.Main right after LoadSettings(), before any window or the native menu bar is built - Replace the duplicated inline load in MainView with the shared call - Also fix a pre-existing warning: DataGridRow.GetIndex() (obsolete) -> .Index Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11505.
Problem
On macOS, after changing the UI language and restarting SE, the native top menu bar (File, Edit, Tools, …) shows in English even though the rest of the window is correctly localized.
Root cause
The native
NSMenuBaris built inProgram.Mainimmediately afterSetupMainWindow, andInitNativeMacMenu.MakeStructurereadsSe.Languagedirectly. But the translation was loaded insideMainView.Build(), which (as anAvalonia.Markup.DeclarativeViewBase) runs lazily on attach duringlifetime.Start()— i.e. after the native menu has already been constructed from the default English strings.Runtime language switches were never affected because they call
InitNativeMacMenu.Rebuild().Fix
Se.LoadLanguage()— loads the translation named in settings intoSe.Language(English / missing / unreadable file ⇒ English defaults, errors logged).Program.Mainright afterSe.LoadSettings(), before any window or the native menu bar is built. This is the actual fix.MainViewwith the shared call (and drop two now-unused imports).DataGridRow.GetIndex()(obsolete) →.Index.Build is 0 warnings, 0 errors.
Verification
Confirmed on macOS (Apple Silicon): set UI language to a non-English translation, restart — the native menu bar now appears localized. English startup path verified healthy.
🤖 Generated with Claude Code