Skip to content

Add Simplified Chinese language support - #15

Merged
JuneQQQ merged 1 commit into
mainfrom
feature/i18n-chinese
May 18, 2026
Merged

Add Simplified Chinese language support#15
JuneQQQ merged 1 commit into
mainfrom
feature/i18n-chinese

Conversation

@JuneQQQ

@JuneQQQ JuneQQQ commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

Adds Simplified Chinese support — the whole game (event log, roles, agent
speech, CLI) can now run in English or Chinese. Requested by the project owner.

deepwolf simulate --players 7 --seed 1 --lang zh

Changes

  • New deepwolf/i18n.py — a Translator with an en/zh message catalogue
    covering every game event, role name, role summary and faction label. It is a
    leaf module (imports nothing else from deepwolf).
  • engine.py — all player-facing event text now flows through the Translator.
    English output is byte-for-byte unchanged (the reproducibility tests still
    pass without modification).
  • GameConfig gains a validated lang field; PlayerView carries lang.
  • prompts/templates.py — bilingual LLM prompts (system message, asks, format
    instructions). The [[ACTION ...]] trailer now carries lang= so the offline
    MockProvider answers in the right language; JSON reply keys stay English.
  • RandomAgent and MockProvider emit localised statements.
  • cli.py — a --lang {en,zh} flag on simulate and play; localised outcome
    panel.
  • Adds README.zh-CN.md and links it from the English README.

Checklist

  • ruff check . passes
  • mypy deepwolf passes
  • pytest passes (60 tests; 9 new for i18n)
  • English output unchanged — existing reproducibility tests untouched
  • CHANGELOG.md and README.md updated

Notes for reviewers

The design keeps i18n out of the hot path: the engine holds one Translator
and English strings are identical to before, so no existing game, transcript or
seed changes behaviour. Adding a third language is just another column in the
i18n.py catalogue.

The whole game can now run in English or Simplified Chinese.

- new deepwolf/i18n.py: a Translator with a message catalogue covering every
  event, role name, role summary and faction label in en + zh.
- engine.py: all player-facing event text now goes through the Translator;
  English output is byte-for-byte unchanged.
- GameConfig gains a validated `lang` field; PlayerView carries `lang`.
- prompts/templates.py: bilingual LLM prompts; the ACTION trailer carries the
  language so the offline mock answers in the right tongue.
- agents: RandomAgent and MockProvider produce localised statements.
- cli.py: a --lang {en,zh} flag on `simulate` and `play`; localised outcome.
- adds README.zh-CN.md and 9 new tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JuneQQQ

JuneQQQ commented May 18, 2026

Copy link
Copy Markdown
Owner Author

Code review (post-merge record).

  • The decisive design choice: the engine holds one Translator and English message strings are byte-identical to the previous inline f-strings. Verified — every reproducibility test passed without modification, so no existing game, seed or transcript changed behaviour. ✅
  • i18n.py is a true leaf module (no deepwolf imports), so any layer can use it and there is no import-cycle risk. ✅
  • Player ids (P0) are kept verbatim in both languages — only prose is translated, so machine-readable references stay stable. ✅
  • The [[ACTION ... lang=]] trailer is the right channel: it keeps the offline mock language-aware without coupling it to prompt prose, and JSON reply keys stay English so parsing is unchanged. ✅
  • Missing translations fall back to English (and unknown keys to the key itself) — graceful, and a good test covers it. ✅
  • CI green on 3.10–3.12.

Adding a third language is now just another column in the catalogue. Merged via squash.

@JuneQQQ
JuneQQQ merged commit 2f07336 into main May 18, 2026
4 checks passed
@JuneQQQ
JuneQQQ deleted the feature/i18n-chinese branch May 18, 2026 11:58
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.

1 participant