feat(i18n): localize sandbox elevation dialog across 7 locales#2892
feat(i18n): localize sandbox elevation dialog across 7 locales#2892gordonlu wants to merge 2 commits into
Conversation
|
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 Please read |
There was a problem hiding this comment.
Code Review
This pull request localizes the sandbox elevation dialog in the TUI across multiple languages by updating ElevationView and ElevationWidget to accept and utilize the active Locale. It also adds comprehensive rendering tests for English and Chinese. Feedback suggests replacing #[allow(dead_code)] with #[cfg(test)] for methods only used in tests to prevent compiling unused code into production, and using the Unicode escape sequence \u{26a0} instead of the literal ⚠ character in the English localization for consistency and robust rendering.
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.
|
|
||
| impl ElevationOption { | ||
| /// Get the display label for this option. | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Since ElevationOption::label is no longer used in production code and is only referenced within tests, it is better to conditionally compile it using #[cfg(test)] instead of silencing the dead code warning with #[allow(dead_code)]. This prevents unused code from being compiled into the production binary.
| #[allow(dead_code)] | |
| #[cfg(test)] |
| } | ||
|
|
||
| /// Get a short description. | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Since ElevationOption::description is no longer used in production code and is only referenced within tests, it is better to conditionally compile it using #[cfg(test)] instead of silencing the dead code warning with #[allow(dead_code)]. This prevents unused code from being compiled into the production binary.
| #[allow(dead_code)] | |
| #[cfg(test)] |
| } | ||
|
|
||
| // Sandbox elevation dialog. | ||
| MessageId::ElevationTitleSandboxDenied => " ⚠ Sandbox Denied ", |
There was a problem hiding this comment.
For consistency with all other localized resources in this PR (which use \u{26a0}), and to ensure robust rendering across different terminal emulators and editors, please use the Unicode escape sequence \u{26a0} instead of the literal ⚠ character.
| MessageId::ElevationTitleSandboxDenied => " ⚠ Sandbox Denied ", | |
| MessageId::ElevationTitleSandboxDenied => " \u{26a0} Sandbox Denied ", |
6d6c98d to
0e4dbc5
Compare
|
Thanks @gordonlu — we merged #2891 and #2896 from your i18n batch tonight, which moved Since the slices all touch |
|
/lgtm |
Understood. Working on it now. Will rebase and push in the suggested order. |
0e4dbc5 to
ba56262
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
ba56262 to
19326f9
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Migrates the sandbox elevation dialog (
ElevationWidget/ElevationView) from hardcoded English strings toMessageId-based translations covering all 7 shipped locales (En, Ja, ZhHans, ZhHant, PtBr, Es419, Vi).Changes
localization.rs: 18 newMessageIdvariants for elevation titles, field labels, impact copy, option labels/descriptions — all 7 locale translationswidgets/mod.rs: replaced all hardcoded English strings inElevationWidget::render()withtr()calls; addedlocalefieldapproval.rs:ElevationView::new(request, locale)with locale field, passes to widgetui.rs: passesapp.ui_localetoElevationView::new()Verification
cargo check— 0 warningscargo test -- elevation— 13/13 pass (including zh locale + English leak detection)cargo test -- approval— 96/96 passcargo test -- localization— 8/8 passcargo fmt— cleanGreptile Summary
Migrates the sandbox elevation dialog from hardcoded English strings to the existing
MessageId/tr()localization system, covering all 7 shipped locales consistently.localization.rs: Adds 18 newMessageIdvariants (titles, field labels, impact lines, option labels/descriptions) with translations in En, Ja, ZhHans, ZhHant, PtBr, Es419, and Vi; each non-English locale uses an exhaustiveSome(match …)block so a missing translation is a compile error.widgets/mod.rs/approval.rs/ui.rs:ElevationWidgetandElevationViewgain alocale: Localefield;app.ui_localeis wired in at the one call-site;label()/description()are narrowed to#[cfg(test)].Confidence Score: 5/5
Safe to merge — the change is purely additive (new MessageIds + tr() call-sites) with no behavioral changes to sandbox policy decisions, key bindings, or event routing.
The localization wiring is mechanical and low-risk: each non-English locale function uses an exhaustive match so a missing translation is a compile error rather than a silent fallback gap. The tr() fallback chain guarantees English output even if a locale entry is somehow absent at runtime. No logic, auth boundaries, or data paths are touched.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant UI as ui.rs (run_event_loop) participant AV as ElevationView (approval.rs) participant EW as ElevationWidget (widgets/mod.rs) participant LOC as tr() / localization.rs UI->>AV: ElevationView::new(request, app.ui_locale) AV->>EW: "ElevationWidget::new(&request, selected, locale)" EW->>LOC: tr(locale, ElevationTitleSandboxDenied) LOC-->>EW: "&'static str (locale-specific or En fallback)" EW->>LOC: tr(locale, ElevationFieldTool / Cmd / Reason) LOC-->>EW: "&'static str" EW->>LOC: tr(locale, ElevationOptionNetwork / Write / FullAccess / Abort) LOC-->>EW: "&'static str" EW-->>AV: rendered ratatui Buffer AV-->>UI: displayed dialogComments Outside Diff (2)
crates/tui/src/tui/approval.rs, line 718-743 (link)label()anddescription()now return hardcoded English strings identical to the English locale translations inlocalization.rs, but are no longer called by the widget. Rather than being removed, they're silenced with#[allow(dead_code)]. If any future call site (CLI output, accessibility layer, snapshot test, or log message) uses these methods instead oftr(), it will silently produce English-only output for all locales. The#[allow(dead_code)]suppression hides the signal that would otherwise prompt a developer to investigate why these exist alongside thetr()path.crates/tui/src/tui/approval.rs, line 1461-1511 (link)The new render tests cover English and Simplified Chinese, but the five remaining locales (Ja, ZhHant, PtBr, Es419, Vi) have no render smoke-test. Additionally, the
en_artifactsleak list intest_elevation_render_zh_hans_localizes_copychecks structural labels but omits option-label leaks like"Allowoutboundnetwork","Fullaccess","Allowextrawriteaccess", and"Abort"— so an untranslated option label would pass the test undetected.Reviews (2): Last reviewed commit: "fix: address review feedback - cfg(test)..." | Re-trigger Greptile