feat(i18n): localize context-inspector surface across 7 locales
Localize all user-facing strings in the compact session context inspector (Alt+C / /context).
Changes
- Add 24
CtxInsp*MessageIds for the context-inspector surface - Pass
localethroughbuild_context_inspector_text()→ helper functions - Wire
tr()for section headers, labels (Model / Workspace / Session / Context / Transcript / Workspace status), status words (ok / high / critical / included / attached / not included / output captured / no output yet), empty-state messages, and the pager title - Add
inspector_localizes_to_zh_hanssmoke test
Files
| File | Δ |
|---|---|
crates/tui/src/localization.rs |
+226 |
crates/tui/src/tui/context_inspector.rs |
+131/-48 |
crates/tui/src/tui/ui.rs |
+5/-1 |
Greptile Summary
This PR localizes the compact session context inspector (Alt+C / /context) across 7 locales by adding 45 CtxInsp* MessageId variants and wiring tr() calls throughout the build_context_inspector_text call tree. It also refactors context_status from returning raw &'static str literals to returning a typed ContextPressure enum, eliminating the silent fallback that was flagged in a previous review.
- New MessageIds (45 total): cover section headers, metric labels (Model/Workspace/Session/Context/Transcript), status words, unit nouns (tokens/blocks/cells/layers), empty-state messages, and the pager title — all properly wired through
tr()in bothcontext_inspector.rsandui.rs. ContextPressureenum: replaces the raw\"critical\"/\"high\"/\"ok\"string dispatch; the exhaustive match now guarantees new pressure tiers are handled explicitly.- Smoke test added:
inspector_localizes_to_zh_hansvalidates that key Simplified-Chinese labels appear and no English labels leak, complementing the existing English-locale tests updated to passLocale::En.
Confidence Score: 5/5
Safe to merge — the change is additive (new MessageIds, tr() wiring) and the refactor to ContextPressure enum removes a previously fragile raw-string dispatch.
All strings that were previously hardcoded English are now routed through tr(). The context_status refactor to ContextPressure makes the match exhaustive so future tiers cannot silently fall through to ok. Every existing test was updated to pass Locale::En and a new zh-hans smoke test covers both positive presence and negative leak checks. Translations are provided for all 7 declared locales; Traditional Chinese correctly delegates unhandled ids to Simplified Chinese. No logic regressions are introduced.
No files require special attention.
Important Files Changed
| Filename | Overview |
|---|---|
| crates/tui/src/localization.rs | Adds 45 new CtxInsp* MessageId variants to the enum and ALL_MESSAGE_IDS slice, then provides translations across all 7 supported locales (English, Vietnamese, Traditional Chinese, Japanese, Simplified Chinese, Portuguese/BR, Spanish/LATAM). Each locale function is updated consistently; Traditional Chinese correctly falls through to Simplified Chinese for any ids it doesn't override. |
| crates/tui/src/tui/context_inspector.rs | Threads locale: Locale through build_context_inspector_text and all helper functions; replaces every hardcoded English string with tr() calls; refactors context_status to return the new ContextPressure enum for exhaustive matching. Existing tests updated to pass Locale::En, and a new zh-hans smoke test verifies translation coverage end-to-end. |
| crates/tui/src/tui/ui.rs | Minimal change: imports {MessageId, tr}, passes app.ui_locale to build_context_inspector_text, and replaces the hardcoded pager title string with tr(app.ui_locale, MessageId::CtxInspTitle). |
| .claude/settings.json | New Claude Code permissions file allowing standard Cargo and filesystem commands used during development; unrelated to the feature but not harmful. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["open_context_inspector(app)"] --> B["build_context_inspector_text(app, app.ui_locale)"]
B --> C["tr(locale, CtxInspSessionContext)\nModel / Workspace / Session labels"]
B --> D["context_status(percent)\n→ ContextPressure enum"]
D -->|Critical| E["tr(locale, CtxInspCritical)"]
D -->|High| F["tr(locale, CtxInspHigh)"]
D -->|Ok| G["tr(locale, CtxInspOk)"]
B --> H["push_system_prompt_structure(out, app, locale)"]
H --> H1["Blocks arm\ntr(CtxInspStablePrefix / CtxInspVolatileWorkingSet\n/ CtxInspBlocks / CtxInspBlock / CtxInspTokens)"]
H --> H2["Text arm\nlayer.kind.label(locale)\n→ tr(CtxInspCacheFriendly | CtxInspChangesByTurn)"]
H --> H3["None arm\ntr(CtxInspNoSystemPrompt)"]
H --> H4["tr(CtxInspCacheTip)"]
B --> I["push_references(out, refs, locale)"]
I --> I1["tr(CtxInspIncluded / CtxInspAttached / CtxInspNotIncluded)\ntr(CtxInspMoreReferences)\ntr(CtxInspNoReferences)"]
B --> J["push_tools(out, app, locale)"]
J --> J1["push_tool_row(out, locale, location, detail)\ntr(CtxInspActive | CtxInspCell)\ntr(CtxInspOutputCaptured | CtxInspNoOutputYet)"]
J --> J2["tr(CtxInspNoToolActivity | CtxInspAltVHint)"]
A --> K["tr(app.ui_locale, CtxInspTitle)\n→ PagerView title"]
Comments Outside Diff (1)
-
crates/tui/src/tui/context_inspector.rs, line 326-328 (link)The overflow line
"- ... {remaining} more reference(s)"is user-facing but has no translation. When references exceedMAX_REFERENCE_ROWS, non-English users receive a raw English notice while every other string on that screen is localized.
Reviews (7): Last reviewed commit: "feat(i18n): localize context-inspector s..." | Re-trigger Greptile
[!WARNING] You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!
Thanks @gordonlu. This is a useful i18n direction, but I’m not harvesting it into the v0.8.50 release branch yet because the current patch still leaves part of the context-inspector surface in English and the status handling is a little too stringly for a release cut.
Concrete next steps that would make this much easier to land:
- finish or explicitly scope the remaining hardcoded inspector strings: transcript units like
cells/API messages, tool-location labels likeactive/cell N, the reference overflow line, and the system-prompt/body explanatory strings; - replace the
context_statusstring dispatch with a typed enum or another exhaustive status representation so translators do not depend on matching English status text; - add at least one smoke assertion for
ZhHansproving the localized inspector does not leak the common English labels above; - rerun CI after those changes. If the macOS stale-session MCP test flakes again with the same connection-reset shape, a rerun is fine, but the localization patch itself should still be green before merge.
The idea has value; it just needs that last precision pass before it belongs in this release lane.
Hey @gordonlu — really excited to see the i18n coverage expanding to the context inspector! The queue and fanout PRs (#2568, #2566) landed beautifully in v0.8.50.
For this one, a couple of things before it's harvest-ready:
- There are still a few hardcoded English strings in the context inspector that need MessageId variants.
- The status handling would benefit from typed variants rather than raw string matching — this makes the localization fallback chain more predictable.
The structure is solid — it's mostly filling in the remaining spots. Happy to review when you've got those addressed. No rush — i18n is a marathon, not a sprint! 🌐🐋