Skip to content

macOS: fix duplicate Window menu in translated UIs - #683

Open
evilja wants to merge 1 commit into
TypesettingTools:masterfrom
evilja:fix-duplicate-macos-window-menu
Open

macOS: fix duplicate Window menu in translated UIs#683
evilja wants to merge 1 commit into
TypesettingTools:masterfrom
evilja:fix-duplicate-macos-window-menu

Conversation

@evilja

@evilja evilja commented Aug 20, 2026

Copy link
Copy Markdown

Problem

On macOS, any non-English UI shows two Window menus in the menu bar — the app's own translated one plus an untranslated "Window" appended after Help. In a Turkish UI that reads PencereYardım Window.

Cause

wxMenuBarCocoaImpl::MacCreateOrFindWindowMenu() (src/osx/cocoa/menu.mm) locates the Window menu by comparing each top-level menu title against two strings:

  • wxStripMenuCodes(wxApp::s_macWindowMenuTitleName), and
  • wx's own translation of "Window" in context "macOS menu name".

Aegisub never sets s_macWindowMenuTitleName, so it keeps wx's default "Window". wx's contextual translation is also "Window" unless a catalog supplies that exact msgctxt/msgid pair. A translated menubar title therefore matches neither, and wx falls through to the branch that allocates a fresh NSMenu titled "Window" and inserts it after the Help menu.

Aegisub already tells wx the translated Help title via wxApp::s_macHelpMenuTitleName; there is simply no equivalent for Window.

Fix

Set s_macWindowMenuTitleName from the menubar entry's already-translated title while the menubar is built, and mark the macOS menubar's Window entry with "special": "window" so the loop can recognise it. wx then matches Aegisub's existing menu, creates nothing extra, and the title stays translated.

The title is assigned before MacSetCommonMenuBar(), so it is in place by the time wx installs the menubar.

Testing

Reproduced on macOS 26 (arm64) with the UI language set to Turkish: two menus, Pencere and Window.

The matching behaviour was confirmed by driving wx's other match path — adding msgctxt "macOS menu name" / msgid "Window" / msgstr "Pencere" to the Turkish catalog makes wx recognise the existing menu, and the duplicate disappears while the title stays Pencere. This patch achieves the same match from the application side, so it works for every locale without requiring a catalog entry per language.

Note, not addressed here

The menubar's "special": "help" marker appears to be dead: menubar entries are handled by the loop in menu::GetMenuBar, which reads special only in the else branch (when no submenu is present), while s_macHelpMenuTitleName is set in process_menu_item, which only ever sees entries inside a menu. Help detection currently works via wx's _("&Help") fallback. Left alone to keep this change focused.

wx locates the macOS Window menu by comparing each top-level menu title
against wxApp::s_macWindowMenuTitleName and against its own translation of
"Window" (context "macOS menu name"). Aegisub never sets the former, so in
any non-English UI the menubar's translated Window title matches neither and
wxMenuBarCocoaImpl::MacCreateOrFindWindowMenu() falls through to creating a
second, untranslated "Window" menu, inserting it after Help.

The result is two Window menus side by side, e.g. "Pencere" and "Window" in
a Turkish UI. Every translated macOS build is affected.

Set s_macWindowMenuTitleName from the menubar's already-translated title,
mirroring how the Help menu title is handled, and mark the macOS menubar's
Window entry so it can be recognised. Since wx then matches Aegisub's own
menu, no extra menu is created and the title stays translated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant