Skip to content

feat: add i18n support with zh-CN locale - #53

Merged
danyel117 merged 18 commits into
prevalentWare:mainfrom
LimFang:feat/i18n-zh-cn
Sep 21, 2026
Merged

danyel117 merged 18 commits into
prevalentWare:mainfrom
LimFang:feat/i18n-zh-cn

Conversation

@LimFang

@LimFang LimFang commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds first-class i18n support to goal mode, starting with Simplified Chinese (zh-CN), while preserving English as the default behavior.

Related issue

Closes #52

Changes

  • add a locale option with "en" as the default
  • support "zh-CN" for Simplified Chinese and "auto" for locale detection from LC_ALL, LANG, then the OS/runtime locale
  • add shared English and zh-CN message catalogs without introducing a runtime dependency
  • localize /goal, /pause_goal, and /resume_goal prompt templates and command descriptions
  • localize V1/V2 goal tool descriptions and user-facing goal notices/reports
  • localize continuation, safety-limit wrap-up, system reminder, and compaction prompts
  • localize V1/V2 TUI sidebar, dialogs, toasts, and command-palette text
  • ship src/i18n.ts with the package because the TUI source imports it
  • document the locale option and OpenCode 1 TUI configuration in the README
  • add regression coverage for locale resolution, server surfaces, continuation/wrap-up prompts, and V2 TUI labels

Verification

Local verification was performed with Bun 1.4.2:

  • bun run lint passes
  • bun run typecheck passes
  • bun run build passes
  • dist/server.js was regenerated and committed
  • the i18n-specific regression tests pass
  • the full test suite reaches 277/278 passing locally

The remaining failures are in existing timing-sensitive watchdog/restart tests. Both are reproducible on the unmodified upstream main under the same environment:

  • V2 watchdog no-response counts a failure on idle even with auto_continue false: 1/10 isolated runs passed
  • restart resolves a persisted started pending attempt at the next idle: 37/50 isolated runs passed

The upstream GitHub Actions workflow is still awaiting maintainer approval because this PR originates from a fork.

Checklist

  • bun run test passes

    • Local full-suite result: 277/278 tests passed.

    • The remaining failures are in existing timing-sensitive watchdog/restart tests and are reproducible on the unmodified upstream main under the same Bun 1.4.2 environment:

      • V2 watchdog no-response counts a failure on idle even with auto_continue false: 1/10 isolated runs passed on upstream main
      • restart resolves a persisted started pending attempt at the next idle: 37/50 isolated runs passed on upstream main
  • bun run lint passes

  • bun run typecheck passes

  • bun run build passes and dist/server.js is committed

  • README/docs updated if behavior or options changed

@LimFang
LimFang marked this pull request as ready for review September 18, 2026 03:33

@danyel117 danyel117 left a comment

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.

Thanks for the thorough i18n work. The full local gate passes at efebf958 (lint, typecheck, 278 tests, build, and pack dry-run), but I found three medium localization gaps that need to be addressed before merge:

  1. src/server.ts:1303 and src/server.ts:1992 call continuationPrompt(current) without the configured locale. Both V1 and V2 watchdog rescues therefore fall back to English under locale: "zh-CN". Please pass locale in both paths and add watchdog-level regression tests (not only prompt-builder tests), then rebuild dist/server.js.
  2. src/tui.ts:406, src/tui.ts:438, and src/tui.ts:609 translate the Status label but render the raw protocol value (paused, budgetLimited, etc.); plugin-owned stopReason values are also emitted in English. Please add locale-aware presentation mappings while preserving protocol values internally. The current zh-CN test expecting 状态: paused should assert the translated value instead. User/authored free text should remain unchanged.
  3. src/prompts.ts:139-140 embeds raw lifecycle status and plugin-owned English stop reasons in the zh-CN safety-limit wrap-up prompt. Please format those known values for presentation before interpolation.

@LimFang
LimFang requested a review from danyel117 September 21, 2026 06:36
@LimFang

LimFang commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. All three localization gaps have now been addressed.

Both V1 and V2 watchdog rescue paths now correctly propagate the configured locale, with zh-CN regression coverage added at the watchdog level.
TUI lifecycle statuses and plugin-owned stop reasons are now localized for display, while keeping protocol values unchanged internally. User-provided text is intentionally left untouched.
The zh-CN safety-limit wrap-up prompt now localizes known lifecycle statuses and stop reasons.
Updated the V2 zh-CN TUI expectation from 状态: paused to 状态: 已暂停.
Rebuilt dist/server.js.

Validation results:

bun run lint ✅
bun run typecheck ✅
bun run build ✅
npm pack --dry-run ✅
Full test suite: 279/281 passed on Bun 1.4.2.

The two remaining failures are the previously documented timing-sensitive watchdog/restart tests. They are reproducible on the unmodified upstream main branch under the same environment. All newly added and modified i18n regression tests pass.

@danyel117 danyel117 left a comment

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.

Re-reviewed at 21158c0. The localization gaps are resolved, the Chinese prompts preserve the English safety semantics, and V1/V2 command arguments are structurally escaped to prevent delimiter breakout while keeping legitimate objectives actionable. Local gate: lint, typecheck, 291 tests, build, and pack dry-run all pass. No remaining high/medium review findings.

@danyel117
danyel117 merged commit 3000449 into prevalentWare:main Sep 21, 2026
5 checks passed
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.

[Feature]: i18n support, starting with Chinese (zh-CN)

2 participants