Skip to content

feat(i18n): localize all queue command messages across 7 locales#2568

Open
gordonlu wants to merge 4 commits into
Hmbown:mainfrom
gordonlu:feat/i18n-queue-surface
Open

feat(i18n): localize all queue command messages across 7 locales#2568
gordonlu wants to merge 4 commits into
Hmbown:mainfrom
gordonlu:feat/i18n-queue-surface

Conversation

@gordonlu
Copy link
Copy Markdown
Contributor

@gordonlu gordonlu commented Jun 2, 2026

Summary

Localize all 15 user-facing strings in the /queue command (list/edit/drop/clear) across all 7 shipped locales.

Changes

  • localization.rs — 15 new CmdQueue* MessageId variants with translations in En, Ja, ZhHans, Vi, PtBr, Es419 (ZhHant falls through to ZhHans)
  • queue.rs — wire queue() / list_queue() / edit_queue() / drop_queue() / clear_queue() / parse_index() through tr(locale, MessageId) with named placeholders ({count}, {index})

Testing

  • All 14 existing queue tests pass (set app.ui_locale = Locale::En for deterministic assertions)
  • New queue_messages_are_localized smokes ZhHans output for 已排队的消息 / 提示
  • fmt + clippy clean

Greptile Summary

This PR localizes all 15 user-facing strings in the /queue command family across 7 shipped locales by adding CmdQueue* MessageId variants to localization.rs and threading tr(locale, …) calls through queue.rs. Existing tests are updated to pin Locale::En for deterministic assertions and one ZhHans smoke test is added; two unrelated stall-watchdog timing tests in tests.rs are also refactored to avoid potentially panicking Instant subtraction, but these changes are bundled into the i18n PR.

  • localization.rs: 15 new enum variants added to both MessageId and ALL_MESSAGE_IDS; translations provided for En, Ja, ZhHans, Vi, PtBr, Es419 with ZhHant delegating to Simplified Chinese via the existing other => chinese_simplified(other)? catch-all in traditional_chinese().
  • queue.rs: Each sub-function now reads app.ui_locale and substitutes named placeholders ({count}, {index}) via .replace(); parse_index return type widened from Result<usize, &'static str> to Result<usize, String> to accommodate owned translated error strings.
  • tests.rs: Timing tests for reconcile_turn_liveness rewritten to compute all Instant values as forward offsets from Instant::now() rather than subtracting large durations, which is the correct approach for cross-platform stability.

Confidence Score: 5/5

The queue command localization is mechanical and complete — all 15 strings are covered in every translation function, placeholder substitution is straightforward .replace() calls on static strings, and the fallback chain to English is preserved. No behavioural changes to queue logic.

The change is purely additive: new enum variants, new match arms in translation functions, and call-site wiring. The queue logic itself is unchanged; the only risk surface is a missing or mismatched placeholder ({count}, {index}), and a quick check shows every locale's strings contain the expected placeholder tokens. ZhHant intentionally delegates to Simplified Chinese via the existing catch-all. The two timing test rewrites are correct and logically equivalent to what they replace.

No files require special attention. The tests.rs timing changes are unrelated but harmless.

Important Files Changed

Filename Overview
crates/tui/src/commands/queue.rs All queue subcommands (list/edit/drop/clear) wired through tr(locale, MessageId::*), parse_index return type updated to Result<usize, String>, existing tests updated to fix locale and assert against translated strings, and a new ZhHans smoke test added.
crates/tui/src/localization.rs 15 new CmdQueue* MessageId variants added to the enum and ALL_MESSAGE_IDS slice; English strings defined in english() and all 6 non-English translation functions updated; ZhHant falls through to chinese_simplified via the existing catch-all.
crates/tui/src/tui/ui/tests.rs Two unrelated stall-watchdog timing tests refactored to avoid subtracting a large Duration from Instant::now() (which can panic on Windows near boot); the arithmetic is logically equivalent but bundled into this i18n PR.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["queue(app, args)"] --> B{arg}
    B -->|empty / list| C["list_queue(app)"]
    B -->|edit| D["edit_queue(app, index)"]
    B -->|drop/remove/rm| E["drop_queue(app, index)"]
    B -->|clear| F["clear_queue(app)"]
    B -->|other| G["tr(locale, CmdQueueUsage)\nCommandResult::error"]

    C --> C1["tr(locale, CmdQueueDraftHeader)"]
    C --> C2["tr(locale, CmdQueueNoMessages)"]
    C --> C3["tr(locale, CmdQueueListHeader)\n.replace('{count}', n)"]
    C --> C4["tr(locale, CmdQueueTip)"]

    D --> P["parse_index(index, locale)"]
    E --> P
    P -->|Err| PE["tr(locale, CmdQueueMissingIndex\n/ CmdQueueIndexPositive\n/ CmdQueueIndexMin)"]
    P -->|Ok| D2["tr(locale, CmdQueueEditingMessage)\n.replace('{index}', n)"]
    P -->|Ok| E2["tr(locale, CmdQueueDropped)\n.replace('{index}', n)"]

    F --> F1["tr(locale, CmdQueueAlreadyEmpty\n/ CmdQueueCleared)"]

    subgraph Localization
        TR["tr(locale, id)\n→ translation(locale,id)\n  or english(id)"]
        En["english()"]
        Ja["japanese()"]
        ZhHans["chinese_simplified()"]
        ZhHant["traditional_chinese()\n→ falls through to ZhHans"]
        PtBr["portuguese_brazil()"]
        Es419["spanish_latin_america()"]
        Vi["vietnamese()"]
        TR --> En & Ja & ZhHans & ZhHant & PtBr & Es419 & Vi
    end
Loading

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

Reviews (2): Last reviewed commit: "fix: restore two-line draft header layou..." | 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!

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 2, 2026

Thanks @gordonlu. This is a useful i18n cleanup and the queue-command surface is worth localizing.

I reviewed the code/tests and the remaining blocker is mechanical: CI lint fails at cargo fmt --all -- --check in crates/tui/src/tui/ui/tests.rs around the Windows-safe Instant test hardening. Please run cargo fmt --all, push the formatted result, and rerun CI.

Once formatting is clean, this looks like a reasonable follow-up harvest candidate. I am keeping it out of the v0.8.50 release branch for now only because the release branch is already in final stabilization, not because the idea is weak.

Comment thread crates/tui/src/commands/queue.rs Outdated
Comment on lines +62 to 66
return CommandResult::error(tr(locale, MessageId::CmdQueueAlreadyEditing));
}
let index = match parse_index(index) {
let index = match parse_index(index, locale) {
Ok(index) => index,
Err(err) => return CommandResult::error(err),
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.

P2 "Error: " prefix stays in English for all locales

CommandResult::error unconditionally prepends the English literal "Error: " (see mod.rs line 93: format!("Error: {}", msg.into())). Now that error bodies are translated, a ZhHans user will see "Error: 未找到已排队的消息" — a mixed-language string. This affects every error path added in this PR (CmdQueueAlreadyEditing, CmdQueueNotFound, CmdQueueMissingIndex, etc.). A follow-up to either translate the "Error: " label or restructure CommandResult to carry the prefix separately would complete the localization story.

Fix in Codex Fix in Claude Code Fix in Cursor

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 2, 2026

Hey @gordonlu — the queue command i18n has been harvested into v0.8.50 (#2504)! All 15 user-facing strings across 7 locales landed cleanly. Really appreciate the thorough approach with the smoke test verifying ZhHans output — that's the kind of attention to detail that makes i18n PRs safe to merge. Thank you! 🌐🐋

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