Skip to content

fix: localize macOS menu role labels - #184

Merged
Astro-Han merged 1 commit into
devfrom
codex/fix-i177-menu-i18n
Apr 23, 2026
Merged

fix: localize macOS menu role labels#184
Astro-Han merged 1 commit into
devfrom
codex/fix-i177-menu-i18n

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Summary

Localizes macOS desktop menu role-backed items in Chinese while keeping Electron roles attached for native behavior.

Why

Closes #177. PawWork custom menu labels were already localized, but role-only Electron menu items still rendered in English in Chinese locale.

Related Issue

Closes #177

How To Verify

cd packages/desktop-electron && bun test src/main/menu.test.ts src/main/menu-labels.test.ts
bun turbo typecheck --filter=@opencode-ai/desktop-electron
bun turbo test:ci --filter=@opencode-ai/desktop-electron

Screenshots or Recordings

Not captured. This change is covered by menu template tests that assert Chinese labels and preserved Electron roles; a manual macOS menu check is still useful before release.

Checklist

  • I linked the related issue, or stated why there is no issue
  • This PR has type, scope, and priority labels, or I requested maintainer labeling
  • I listed the relevant verification steps, including tests when behavior changed
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for desktop, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, or generated/local file changes when relevant
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

Summary by CodeRabbit

  • New Features

    • Enhanced menu localization with role-specific labels, adding a localized "Window" menu and support for app-name placeholders in menu item text.
  • Bug Fixes

    • Role-backed menu items now consistently show localized labels while keeping their original behavior.
  • Tests

    • Added tests validating localized role-based menu labels (including Chinese) and the window submenu.

@Astro-Han Astro-Han added bug Something isn't working P2 Medium priority platform Electron shell, OS integration, packaging, updater, signing, paths, and permissions labels Apr 23, 2026
@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9da074fa-ec60-4c47-b149-4cafc992c703

📥 Commits

Reviewing files that changed from the base of the PR and between 0df56eb and 92abb1d.

📒 Files selected for processing (3)
  • packages/desktop-electron/src/main/menu-labels.ts
  • packages/desktop-electron/src/main/menu-template.ts
  • packages/desktop-electron/src/main/menu.test.ts
📝 Walkthrough

Walkthrough

Adds localized labels for Electron role-backed menu items: new MenuRoleLabelKey type, roleLabels (en/zh), and menuRoleLabel(); integrates localized label values into the menu template (preserving role fields) and updates tests to assert localized role-backed labels.

Changes

Cohort / File(s) Summary
Menu Localization
packages/desktop-electron/src/main/menu-labels.ts
Adds MenuRoleLabelKey union, expands MenuLabelKey with "window", introduces roleLabels (English/Chinese) and exported menuRoleLabel(locale, key, appName) which falls back to English, warns in DEV when missing, and substitutes {appName}.
Menu Template
packages/desktop-electron/src/main/menu-template.ts
Imports menuRoleLabel, adds helper to build localized labels for role items, sets explicit label: ... alongside existing role entries across app/file/edit/view/window menus, and replaces bare role: "windowMenu" with a labeled window submenu containing localized role children.
Tests
packages/desktop-electron/src/main/menu.test.ts
Adds helpers to locate menu items and assert role+label pairs; adds integration tests building menus for zh and en and verifying role-backed items render localized labels while keeping their role values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I nibble keys and hop with cheer,

Menu labels speak both far and near,
"窗口" and "Window" now side by side,
I twitch my nose — locales aligned.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding localization for macOS menu role labels, which is the core objective addressed in this PR.
Linked Issues check ✅ Passed The PR successfully addresses issue #177 by implementing localized labels for all role-backed menu items while preserving Electron roles for native behavior and shortcuts, with comprehensive test coverage.
Out of Scope Changes check ✅ Passed All code changes are directly scoped to localizing macOS menu role labels as specified in issue #177; no unrelated modifications detected.
Description check ✅ Passed The pull request description follows the template and includes all required sections with sufficient detail.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-i177-menu-i18n

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces localized labels for Electron menu roles in English and Chinese, ensuring a consistent user interface across different locales. It adds a new menuRoleLabel utility to handle translations with application name placeholders and updates the menu template to explicitly set labels for role-based items. A critical issue was identified in the 'Window' menu: removing the windowMenu role on macOS disables the OS-managed dynamic list of open windows, so the role should be retained alongside the custom label.

Comment thread packages/desktop-electron/src/main/menu-template.ts
@Astro-Han
Astro-Han force-pushed the codex/fix-i177-menu-i18n branch from a8cf99c to d446cbd Compare April 23, 2026 07:45

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

P1 (required): 1 issue
P2 (suggested): 2 issues
P3 (optional): 2 issues

Overall the implementation is solid, but a few areas need attention before merge.

Comment thread packages/desktop-electron/src/main/menu.test.ts
Comment thread packages/desktop-electron/src/main/menu-template.ts
Comment thread packages/desktop-electron/src/main/menu-template.ts
Comment thread packages/desktop-electron/src/main/menu-labels.ts Outdated
Comment thread packages/desktop-electron/src/main/menu-labels.ts Outdated
@Astro-Han

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Astro-Han
Astro-Han force-pushed the codex/fix-i177-menu-i18n branch from d446cbd to 0df56eb Compare April 23, 2026 08:24

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: fix: localize macOS menu role labels

Thorough nitpick review. The approach is sound but a few issues worth addressing.

P1 (1 issue): windowMenu role + custom submenu contradicts Electron docs
P2 (3 issues): redundant English labels, loose test assertions, silent submenu miss
P3 (3 issues): localization accuracy, readability, locale-coverage gap

Key concern: the windowMenu block sets both role and submenu. Electron docs say role takes precedence and other properties are ignored, which would silently discard the custom submenu and defeat the localization goal. Needs either a code comment documenting the tested behavior, or a restructure to avoid the conflict.

Comment thread packages/desktop-electron/src/main/menu-template.ts
Comment thread packages/desktop-electron/src/main/menu-labels.ts
Comment thread packages/desktop-electron/src/main/menu.test.ts
Comment thread packages/desktop-electron/src/main/menu.test.ts
Comment thread packages/desktop-electron/src/main/menu-labels.ts Outdated
Comment thread packages/desktop-electron/src/main/menu-template.ts Outdated
Comment thread packages/desktop-electron/src/main/menu-labels.ts
@Astro-Han
Astro-Han force-pushed the codex/fix-i177-menu-i18n branch from 0df56eb to 92abb1d Compare April 23, 2026 08:52
@Astro-Han
Astro-Han merged commit 77793b4 into dev Apr 23, 2026
23 checks passed
@Astro-Han
Astro-Han deleted the codex/fix-i177-menu-i18n branch April 23, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working P2 Medium priority platform Electron shell, OS integration, packaging, updater, signing, paths, and permissions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Desktop menu role items remain English in Chinese locale

1 participant