Skip to content

feat(i18n): localize context-inspector surface across 7 locales#2572

Open
gordonlu wants to merge 1 commit into
Hmbown:mainfrom
gordonlu:feat/i18n-context-inspector
Open

feat(i18n): localize context-inspector surface across 7 locales#2572
gordonlu wants to merge 1 commit into
Hmbown:mainfrom
gordonlu:feat/i18n-context-inspector

Conversation

@gordonlu
Copy link
Copy Markdown
Contributor

@gordonlu gordonlu commented Jun 2, 2026

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 locale through build_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_hans smoke 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 both context_inspector.rs and ui.rs.
  • ContextPressure enum: 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_hans validates that key Simplified-Chinese labels appear and no English labels leak, complementing the existing English-locale tests updated to pass Locale::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"]
Loading

Comments Outside Diff (1)

  1. crates/tui/src/tui/context_inspector.rs, line 326-328 (link)

    P2 The overflow line "- ... {remaining} more reference(s)" is user-facing but has no translation. When references exceed MAX_REFERENCE_ROWS, non-English users receive a raw English notice while every other string on that screen is localized.

    Fix in Codex Fix in Claude Code Fix in Cursor

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (7): Last reviewed commit: "feat(i18n): localize context-inspector s..." | Re-trigger Greptile

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Comment thread crates/tui/src/tui/context_inspector.rs
Comment thread crates/tui/src/tui/context_inspector.rs Outdated
Comment thread crates/tui/src/tui/context_inspector.rs Outdated
@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 2, 2026

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 like active / cell N, the reference overflow line, and the system-prompt/body explanatory strings;
  • replace the context_status string 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 ZhHans proving 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.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 2, 2026

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:

  1. There are still a few hardcoded English strings in the context inspector that need MessageId variants.
  2. 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! 🌐🐋

@gordonlu gordonlu force-pushed the feat/i18n-context-inspector branch from 0def0a8 to 2ad73c4 Compare June 2, 2026 06:24
Comment thread crates/tui/src/localization.rs
@gordonlu gordonlu force-pushed the feat/i18n-context-inspector branch 3 times, most recently from 8a14157 to 601f83a Compare June 2, 2026 06:50
@gordonlu gordonlu force-pushed the feat/i18n-context-inspector branch from 601f83a to 3d04816 Compare June 2, 2026 06:51
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