feat: i18n / locale support for user-facing messages#125
Open
IyadhKhalfallah wants to merge 1 commit into
Open
feat: i18n / locale support for user-facing messages#125IyadhKhalfallah wants to merge 1 commit into
IyadhKhalfallah wants to merge 1 commit into
Conversation
Adds a `locale` config field (falls back to $LANG, then "en") and a
lightweight t() helper backed by src/locales/{en,es}.json. All ~190
user-facing strings across cli.ts, install.ts, tui/dashboard.tsx, and
hooks/user-prompt-submit.ts now route through t() with {var}
interpolation.
Smoke-tested: LANG=es node dist/cli.js --help renders full Spanish.
Key-parity test (src/locales.test.ts) fails CI if a new key is added
to en.json without matching es.json, or if placeholder vars drift
between locales.
Known limitations (for a follow-up Phase 2):
- Hub errors from /api/v1/* still flow back in English
- continue.command literal is translated but the hook's continue-
prompt regex is English-only
esmelyvaldivieso99-code
added a commit
to esmelyvaldivieso99-code/clauditor
that referenced
this pull request
Apr 17, 2026
…nue prompts Review of IyadhKhalfallah#125 translation. Two related changes: 1) src/locales/es.json — align phrasing to Latin American Spanish (the user who filed IyadhKhalfallah#122 is LATAM) and fix two visual issues: - Monitorización → Monitoreo - Coste → Costo (status.costLine, stats.estCost) - punta → pico (horas pico) across time.* and cli.cmd.time.desc - pulsa Enter → presiona Enter (block.orContinue) - "Escrituras cch:" → "Escrit. caché:" (truncated label was unclear) - "DESP." → "DESPERD." in report.columns (DESP. can read as "después" in Spanish — ambiguous) 2) src/hooks/user-prompt-submit.ts — extend CONTINUE_PATTERNS with Spanish variants so the translated `continue.command` string still triggers the handoff injection. Addresses known limitation IyadhKhalfallah#2 in the PR description: continúa, continuemos, sigue donde/desde/con, retoma, reanuda, dónde (nos) quedamos, qué estábamos haciendo, "… y continúa donde …" (matches the default es.json command line) Tested - npx tsc --noEmit: clean - npx vitest run src/locales.test.ts src/i18n.test.ts: 16/16 pass (key-parity + placeholder-var parity preserved) - npm run build: clean - LANG=es node dist/cli.js --help: renders Spanish correctly Note: 10 time-dependent tests in feat/i18n-locale-support (pre-tool-use, project-brief, file-index, error-index, decay, time-analysis) are pre-existing failures — they reproduce on the base branch without these changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #122.
Summary
localefield to~/.clauditor/config.json(falls back to$LANG, thenen)t()helper insrc/i18n.tsbacked bysrc/locales/{en,es}.jsoncli.ts,install.ts,tui/dashboard.tsx, andhooks/user-prompt-submit.tsnow route throught()with{var}interpolationes.jsonto refine)Test plan
npx tsc --noEmit— cleannpx vitest run— 356/356 tests pass (16 new acrossi18n.test.ts+locales.test.ts)npm run build— tsup bundles JSON inline, no runtime FS callLANG=es node dist/cli.js --helprenders full Spanishclauditor install/clauditor loginstill work in English (default)New tests
src/i18n.test.ts— fallback behavior, interpolation, locale code normalization (es_ES.UTF-8→es, etc.), env loadingsrc/locales.test.ts— key parity betweenen.jsonandes.json+ placeholder-var parity. Fails CI the moment someone adds a newenkey without translating it, or drifts interpolation params between locales.Design notes
feature.subkey(e.g.,block.title,sessions.minAgo).\x1b[...].Known limitations (Phase 2 follow-up)
/api/v1/*) returns{ error: "..." }strings that the CLI prints verbatim viasrc/hub/client.ts:64-65. A full i18n UX requires changing the API contract to return error codes. Out of scope for this PR.continue.commandround-trip. The translated string "lee {path} y continúa donde lo dejé" is what the hook shows a Spanish user to copy-paste; but the hook's own continue-prompt detection regex is English-only. If a Spanish user pastes the translated line back, detection won't fire. Options: keep that specific string English-only, or extend the regex to recognize Spanish forms. Worth a follow-up issue.dashboard.tsx("Cache:", "Turns:") and literal shell commands (claude mcp add ...) are intentionally not translated.How translators can contribute
Only need to touch one file per language:
src/locales/<lang>.json. The key-parity test will flag any drift.