Skip to content

feat(i18n): the shortcut rows speak Chinese - #391

Merged
simion merged 1 commit into
simion:mainfrom
lymanzhao:feat/i18n-shortcuts
Oct 10, 2026
Merged

simion merged 1 commit into
simion:mainfrom
lymanzhao:feat/i18n-shortcuts

Conversation

@lymanzhao

@lymanzhao lymanzhao commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

The Shortcuts settings page was half translated: its own chrome (the subtitle, Reset all, the conflict note) had locale entries from #330, and every row under it did not. Those row labels and hints were English strings in src/lib/shortcuts.ts, so a Chinese UI drew a Chinese page whose whole list was English. The ⌘/ cheat sheet draws the same rows and was in the same state.

This moves that copy into the locale files, under settings:shortcuts.*, and adds src/lib/shortcutCopy.ts as the id to key map plus the accessors both surfaces read. One copy is the only way the settings list and the sheet cannot disagree about what a command is called, and a new ShortcutId is a compile error until it has a key there.

Shortcut ids are untouched: they are what prefs stores the binding map under, so nothing migrates. English is unchanged word for word, which keeps the specs that assert on it valid.

Pieces:

  • lib/shortcutCopy.ts: a Record<ShortcutId, string> key table, the {{cmd}} style chord variables the hints interpolate, and the accessors (shortcutLabel, shortcutHint, shortcutGroupLabel, fixedShortcut*, doubleShiftModeLabel, ctrlTabModeLabel).
  • lib/shortcuts.ts: the registry drops label / hint / fixedReason and keeps structure (ids, groups, bindings, glyphs). DOUBLE_SHIFT_MODES and CTRL_TAB_MODES become id lists.
  • locales/{en,zh-CN}/settings.ts: copy for 43 rows, the 2 fixed gestures, the mode selects and the group headings.
  • lib/shortcutCopy.test.ts: keys built from a table are invisible to usedKeys.test.ts (literals only) and to parity.test.ts (en against zh-CN only, so a row missing from BOTH passes it), which is exactly the failure that would ship here: a row drawing its own key on screen.
  • e2e/specs/i18n.e2e.ts: a case that opens the page in Chinese and reads the row labels and the mode select's options back, with an English control beside it.

Two strings stay English on purpose:

  • The Code navigation group heading. That name is the feature's own (lib/lsp/featureName.ts), it follows the type-checking switch, and four other surfaces call it that. A second name for it here is the drift that file exists to prevent, so localizing the feature name itself is its own change.
  • "Super" in the Linux-only hint, as before.

Suites: npm test 3104 passed, npm run typecheck:e2e clean, and e2e/specs/i18n.e2e.ts green at 7 cases including the new one. The full make e2e run reported 29 of 31 spec files passing with two failing; I could not read which two (the log was tailed) and could not re-run them afterwards, because a dev build had replaced the e2e binary. The shortcut-related specs should be read as verified, the rest of that run as unverified here.

Screenshots: the e2e case writes two, .e2e/artifacts/settings-shortcuts-en.png (the English page, unchanged) and settings-shortcuts-zh.png (the Chinese one, rows and all). The upload API refuses from this setup, so they still need a drag and drop into this description.

Manually tested by hand: the Shortcuts page was opened in Chinese and reads as it should. The screenshots come from the e2e run.

Co-Authored-By: Claude Code noreply@anthropic.com

The Shortcuts settings page and the ⌘/ cheat sheet drew their row labels and
hints from English strings in lib/shortcuts.ts, so a Chinese UI showed a
Chinese page whose every row was English. The page's own chrome (subtitle,
Reset all, the conflict note) had locale entries; the rows under it did not.

The copy moves into the locale files (settings:shortcuts.*) and
lib/shortcutCopy.ts becomes the id -> key map plus the accessors both
surfaces read. One copy is the only way the settings list and the sheet
cannot disagree about what a command is called, and a new ShortcutId is a
compile error until it has a key there.

The registry keeps structure only (ids, groups, bindings, glyphs) and
DOUBLE_SHIFT_MODES / CTRL_TAB_MODES become id lists. English text is
unchanged, word for word, so the specs that assert on it stay valid.

Keys built from a table are invisible to usedKeys.test.ts (literals only) and
to parity.test.ts (en against zh-CN only: a row missing from BOTH passes it),
so shortcutCopy.test.ts pins them, and i18n.e2e.ts gains a case that opens
the page in Chinese and reads the rows back.

Follow-up to simion#330.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@lymanzhao

Copy link
Copy Markdown
Contributor Author
settings-shortcuts-zh

@simion simion left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verified the 44-id def/hint mapping is complete and parity-tested in both languages, and confirmed no shortcut id changed so there's no keybinding migration risk. Thanks for the contribution!

@simion
simion merged commit bd212b1 into simion:main Oct 10, 2026
7 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.

2 participants