feat(i18n): localize all queue command messages across 7 locales#2568
feat(i18n): localize all queue command messages across 7 locales#2568gordonlu wants to merge 4 commits into
Conversation
|
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 cleanup and the queue-command surface is worth localizing. I reviewed the code/tests and the remaining blocker is mechanical: CI lint fails at 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. |
| 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), |
There was a problem hiding this comment.
"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.
|
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! 🌐🐋 |
Summary
Localize all 15 user-facing strings in the
/queuecommand (list/edit/drop/clear) across all 7 shipped locales.Changes
localization.rs— 15 newCmdQueue*MessageId variants with translations in En, Ja, ZhHans, Vi, PtBr, Es419 (ZhHant falls through to ZhHans)queue.rs— wirequeue()/list_queue()/edit_queue()/drop_queue()/clear_queue()/parse_index()throughtr(locale, MessageId)with named placeholders ({count},{index})Testing
app.ui_locale = Locale::Enfor deterministic assertions)queue_messages_are_localizedsmokes ZhHans output for已排队的消息/提示Greptile Summary
This PR localizes all 15 user-facing strings in the
/queuecommand family across 7 shipped locales by addingCmdQueue*MessageId variants tolocalization.rsand threadingtr(locale, …)calls throughqueue.rs. Existing tests are updated to pinLocale::Enfor deterministic assertions and one ZhHans smoke test is added; two unrelated stall-watchdog timing tests intests.rsare also refactored to avoid potentially panickingInstantsubtraction, but these changes are bundled into the i18n PR.localization.rs: 15 new enum variants added to bothMessageIdandALL_MESSAGE_IDS; translations provided for En, Ja, ZhHans, Vi, PtBr, Es419 with ZhHant delegating to Simplified Chinese via the existingother => chinese_simplified(other)?catch-all intraditional_chinese().queue.rs: Each sub-function now readsapp.ui_localeand substitutes named placeholders ({count},{index}) via.replace();parse_indexreturn type widened fromResult<usize, &'static str>toResult<usize, String>to accommodate owned translated error strings.tests.rs: Timing tests forreconcile_turn_livenessrewritten to compute allInstantvalues as forward offsets fromInstant::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.rstiming changes are unrelated but harmless.Important Files Changed
tr(locale, MessageId::*),parse_indexreturn type updated toResult<usize, String>, existing tests updated to fix locale and assert against translated strings, and a new ZhHans smoke test added.CmdQueue*MessageId variants added to the enum andALL_MESSAGE_IDSslice; English strings defined inenglish()and all 6 non-English translation functions updated; ZhHant falls through tochinese_simplifiedvia the existing catch-all.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 endReviews (2): Last reviewed commit: "fix: restore two-line draft header layou..." | Re-trigger Greptile