CodeWhale icon indicating copy to clipboard operation
CodeWhale copied to clipboard

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

Open gordonlu opened this issue 6 months ago • 3 comments

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

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

gordonlu avatar Jun 02 '26 02:06 gordonlu

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

gemini-code-assist avatar Jun 02 '26 02:06 gemini-code-assist

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.

Hmbown avatar Jun 02 '26 02:06 Hmbown

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! 🌐🐋

Hmbown avatar Jun 02 '26 04:06 Hmbown

This was harvested into the v0.8.50 release — thank you for the contribution!

Hmbown avatar Jun 03 '26 03:06 Hmbown