Skip to content

feat(i18n): localize approval dialog surface across 7 locales#2891

Open
gordonlu wants to merge 2 commits into
Hmbown:mainfrom
gordonlu:feat/i18n-approval
Open

feat(i18n): localize approval dialog surface across 7 locales#2891
gordonlu wants to merge 2 commits into
Hmbown:mainfrom
gordonlu:feat/i18n-approval

Conversation

@gordonlu
Copy link
Copy Markdown
Contributor

@gordonlu gordonlu commented Jun 8, 2026

Migrates the approval takeover card (ApprovalWidget) from hardcoded English/ZhHans locale-match functions to MessageId-based translations covering all 7 shipped locales (En, Ja, ZhHans, ZhHant, PtBr, Es419, Vi).

Changes

  • 23 new MessageId variants in localization.rs:
    • ApprovalRiskReview, ApprovalRiskDestructive — risk badges
    • ApprovalCategorySafe, ApprovalCategoryFileWrite, ApprovalCategoryShell, ApprovalCategoryNetwork, ApprovalCategoryMcpRead, ApprovalCategoryMcpAction, ApprovalCategoryUnknown — tool category labels
    • ApprovalFieldType, ApprovalFieldAbout, ApprovalFieldImpact, ApprovalFieldParams — field labels
    • ApprovalOptionApproveOnce, ApprovalOptionApproveAlways, ApprovalOptionDeny, ApprovalOptionAbortTurn — option labels
    • ApprovalBlockTitle — card title word
    • ApprovalControlsHint — footer controls hint
    • ApprovalChooseHint, ApprovalChooseAction — selection hint
    • ApprovalIntentLabel, ApprovalMoreLines — intent summary labels
  • All 7 locale translations for each variant (Ja/ZhHans from existing hardcoded strings, ZhHant adapted, PtBr from old PR, Es419/Vi new)
  • widgets/mod.rs: replaced 13 locale-match functions with tr() calls; extracted color logic from category_label_for()
  • approval.rs: intent label and "more lines" hint now use tr() with named placeholder {count}

Verification

  • cargo check -p codewhale-tui — clean, no warnings
  • cargo test -p codewhale-tui -- approval — 96/96 pass
  • cargo test -p codewhale-tui -- localization — 8/8 pass
  • shipped_first_pack_has_no_missing_core_messages — passes (no locale missing any MessageId)

Greptile Summary

Replaces 13 hardcoded locale-match functions in ApprovalWidget with MessageId-based tr() calls backed by 23 new message IDs covering all 7 shipped locales. The refactor also cleanly separates color logic from label text in category_label_for(), and incidentally improves FanoutCounts wording in Japanese (待機→保留) and Brazilian Portuguese (executando→em execução).

  • localization.rs: Adds 23 MessageId variants with full translations across all 7 locales; all variants are registered in ALL_MESSAGE_IDS and verified by the shipped_first_pack_has_no_missing_core_messages test.
  • widgets/mod.rs: Replaces every locale-match function with tr(locale, MessageId::…) calls; ApprovalMoreLines uses the existing .replace(\"{count}\", …) pattern consistent with FanoutCounts.
  • .claude/settings.json: Adds a project-level Claude Code settings file granting broad shell permissions for cargo-based build and test workflows.

Confidence Score: 5/5

This PR is safe to merge — it is a mechanical substitution of hardcoded strings with looked-up translations, backed by a passing exhaustive-coverage test.

Every changed line is a direct equivalence replacement: locale-match functions that returned a hardcoded string are now tr() calls that resolve to the same string through the translation table. The shipped_first_pack_has_no_missing_core_messages test guarantees no locale is missing any of the 23 new IDs, and the 96/96 approval tests confirm widget rendering is unbroken.

No files require special attention.

Important Files Changed

Filename Overview
crates/tui/src/localization.rs Adds 23 new MessageId variants with complete coverage across all 7 locales; registered in ALL_MESSAGE_IDS and verified by existing tests.
crates/tui/src/tui/widgets/mod.rs Cleanly replaces 13 locale-match functions with tr() calls; splits color/label logic in category_label_for(); ApprovalMoreLines template substitution is consistent with the FanoutCounts pattern already in use.
.claude/settings.json New project-level Claude Code settings granting broad shell permissions (rm *, mv *, cp *) for cargo workflows.

Reviews (2): Last reviewed commit: "fix: restore trailing spaces on English ..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Thanks @gordonlu for taking the time to contribute.

This repository is currently observing a maintainer-managed contribution gate in dry-run mode, so this pull request is staying open. When enforcement is enabled, pull requests from contributors who are not listed in .github/APPROVED_CONTRIBUTORS will be closed automatically.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant PR access by commenting /lgtm on a pull request.

Copy link
Copy Markdown
Contributor

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

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 refactors the approval dialog in the TUI to support localization across multiple languages by defining new message IDs and translations in localization.rs and using them in ApprovalWidget. Feedback highlights a layout regression in the English translation where trailing padding spaces were removed from field labels, which breaks vertical alignment in the UI.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/tui/src/localization.rs Outdated
Comment on lines +1517 to +1519
MessageId::ApprovalFieldAbout => "About:",
MessageId::ApprovalFieldImpact => "Impact:",
MessageId::ApprovalFieldParams => "Params:",
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.

medium

The English translations for ApprovalFieldAbout, ApprovalFieldImpact, and ApprovalFieldParams have lost their trailing padding spaces (originally "About: ", "Impact: ", and "Params: "). This causes a visual layout regression in the English approval dialog, as the description, impacts, and parameters fields will no longer align vertically.

Suggested change
MessageId::ApprovalFieldAbout => "About:",
MessageId::ApprovalFieldImpact => "Impact:",
MessageId::ApprovalFieldParams => "Params:",
MessageId::ApprovalFieldAbout => "About: ",
MessageId::ApprovalFieldImpact => "Impact: ",
MessageId::ApprovalFieldParams => "Params: ",

Comment thread crates/tui/src/localization.rs Outdated
@gordonlu gordonlu force-pushed the feat/i18n-approval branch from d0756c7 to a241654 Compare June 8, 2026 02:05
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