Skip to content

feat: localize selection shortcuts - #2754

Merged
webbrain-one merged 3 commits into
webbrain-one:mainfrom
alectimison-maker:feat/localize-selection-shortcuts
Aug 11, 2026
Merged

feat: localize selection shortcuts#2754
webbrain-one merged 3 commits into
webbrain-one:mainfrom
alectimison-maker:feat/localize-selection-shortcuts

Conversation

@alectimison-maker

Copy link
Copy Markdown
Contributor

Summary

  • localize the floating selection shortcut and native selection context menus for all 23 WebBrain interface locales
  • rebuild native menus when wbLocale changes and apply live locale/RTL updates to the closed-shadow selection surface
  • carry the interface locale into fixed selection actions so responses follow the selected UI language
  • keep action IDs structural, use English per-key fallback, and preserve the existing selection_only grounding and nonce-based untrusted-content boundary

Closes #2746.

Why

The extension already stores the selected interface locale, but the two selection-menu surfaces hardcoded English labels. Fixed actions also omitted that locale when building their model prompt, so a Chinese UI could still produce an English explanation. The implementation resolves one static, offline bundle in the background for both surfaces and adds the allowlisted response-language instruction outside the selected page-content boundary.

Test plan

  • npm test — passed (1624 passed, 0 failed; security corpus 60/60)
  • npm run test:fixtures — new Chrome/Firefox localization, live-switch, RTL, and fixed-action language cases pass; overall 149 passed, 2 failed, with the same two pre-existing selection-dialog keyboard-focus failures as clean main (147 passed, 2 failed before these two new cases)
  • npm run test:webmcp — both functional smoke assertions print PASS; the process then hits the existing 30-second cleanup timeout
  • npm run test:ci — still hits the existing workflow/source assertion mismatch in ci/test.mjs; this PR does not modify either file
  • git diff --check

This PR was implemented and tested with AI assistance. The linked issue comment contains the AI triage disclosure and root-cause analysis.

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@alectimison-maker is attempting to deploy a commit to the esokullu's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Localizes selection shortcuts and context menus across all 23 interface locales while aligning fixed-action responses with the selected language.

Changes:

  • Adds mirrored localization bundles and localized translation targets.
  • Applies live locale/RTL updates and response-language prompting.
  • Expands unit and browser-fixture coverage.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/run.js Tests localization coverage, parity, and prompts.
test/fixtures/run.mjs Tests live localized shortcut behavior.
src/chrome/src/selection-shortcut-i18n.js Adds Chrome localization bundle.
src/firefox/src/selection-shortcut-i18n.js Adds Firefox localization bundle.
src/chrome/src/context-menu-storage.js Adds response-language instructions.
src/firefox/src/context-menu-storage.js Mirrors localized prompt handling.
src/chrome/src/content/selection-shortcut.js Localizes the floating shortcut.
src/firefox/src/content/selection-shortcut.js Mirrors localized shortcut behavior.
src/chrome/src/background.js Localizes and rebuilds Chrome menus.
src/firefox/src/background.js Localizes and rebuilds Firefox menus.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +157 to +158
export function buildContextMenuPrompt(selectionText, language = '') {
return wrapSelectedPageText(selectionText, GENERIC_CONTEXT_MENU_INSTRUCTION + responseLanguageInstruction(language));
Comment on lines +157 to +158
export function buildContextMenuPrompt(selectionText, language = '') {
return wrapSelectedPageText(selectionText, GENERIC_CONTEXT_MENU_INSTRUCTION + responseLanguageInstruction(language));
Comment thread src/chrome/src/content/selection-shortcut.js
Comment thread src/firefox/src/content/selection-shortcut.js
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@webbrain-one

Copy link
Copy Markdown
Owner

Great addition! There are still a couple of open items, if we can close them this'll get merged right away! Thanks!

@webbrain-one
webbrain-one merged commit c487866 into webbrain-one:main Aug 11, 2026
1 of 2 checks passed
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.

Feedback from Chrome store: translate context menus

3 participants