
Game Translator
io.github.dcd887Published by GitHub account dcd887v0.2.1Updated Oct 30, 2026
游戏文本本地化 MCP:多格式解析、批量翻译、回写
Overview
Local MCP server that scans a game folder for plain-text localization files, translates them to Chinese via an OpenAI-compatible API, and writes results to a…
- What you can do
- Scan a game or mod directory and list translatable files with text-volume estimates
- Preview a translation run for free: file counts, entry counts and estimated tokens, without calling AI or writing files
- Run a sampled dry-run translation to check quality before committing
- Translate a whole directory in batches and write results back in the original format, plus a report
- Discover installed, translatable games in the local Steam library
- When to use it
- Useful when you want an assistant to localize a game or mod whose text lives in plain files such as JSON, LANG, TSV, VDF, PO, SRT or ASS, and you are willing to pay for AI translation tokens. Preview first to judge the workload.
- Requirements
- Runs locally as a Python package (Python 3.10 or newer) over stdio. Needs network access and an API key for one OpenAI-compatible provider, configured through variables such as TRANSLATOR_API_KEY with TRANSLATOR_BASE_URL and TRANSLATOR_MODEL, or AGNES_API_KEY, DASHSCOPE_API_KEY or DEEPSEEK_API_KEY. Optional settings include BATCH_SIZE, OUTPUT_DIR and SCAN_MAX_SIZE_MB.
Installation
In SourceWeft
- Open Game Translator in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
mcp-name: io.github.dcd887/game-translator
game-translator-mcp
通用游戏汉化 MCP 工具 —— 扫描游戏目录,调用 AI 翻译,回写中文文本。
定位:一个可以被 AI Agent 调用的「汉化能力」,而非独立的汉化软件。可与 mc-translator-mcp、mc-pack-builder-mcp 等工具协同工作。
适用范围
本工具面向文本以明文文件存储的游戏/模组进行汉化,属于"文本汉化"而非"资源包注入"。
📚 想知道你的游戏在被支持范围内吗? 先看这里 → SUPPORTED_GAMES.md(含已实测游戏、引擎→格式速查表、不支持清单)。 快速判断口诀:文案只要是明文文件就能汉化;不确定就
python -m game_translator_mcp preview <目录>零成本看一眼。
不适用范围 / 已知限制:
- Unity 打包的
.pak/.vpk/catalog.json二进制资源,需先解包才能处理 - 幻兽帕鲁等使用
.locres的 Unreal 游戏,需 UnrealPak 解包 - 战雷 / 绝地求生等服务端下发或加密的文本,不提供破解支持
- 单个文本文件超过大小阈值(默认 10MB,防误扫二进制),扫描时跳过 —— 阈值可用
--max-size-mb N或环境变量SCAN_MAX_SIZE_MB调高(部分游戏明文配置刚好超 10MB 时很有用)
提示:Unity 游戏虽有大量
.json/.xml,但多数是引擎配置而非游戏文案;扫描器会如实返回,是否值得翻译由使用者判断。
使用条件
AI 供应商完全由使用者配置(检测哪个 key 已配置就用哪个,优先级 custom > agnes > dashscope > deepseek):
- 自定义 OpenAI 兼容供应商(推荐,最通用):
TRANSLATOR_API_KEY+TRANSLATOR_BASE_URL+TRANSLATOR_MODEL,任意兼容接口平台都可用 - agnes ai:
AGNES_API_KEY+AGNES_BASE_URL+AGNES_MODEL - 通义千问:
DASHSCOPE_API_KEY - DeepSeek(可选 fallback):
DEEPSEEK_API_KEY
安装
配置
复制 .env.example 为 .env 并填写你要用的供应商:
任选一种方式(检测到哪个 key 就用哪个,优先级 custom > agnes > dashscope > deepseek):
配置优先级:先读环境变量,其次读项目根目录
.env文件,最后为内置默认值。 API Key 由使用者自备,自行寻求对应平台申请(如 agnes / 通义 / DeepSeek / 其它 OpenAI 兼容网关)。
可移植性:本工具不绑定任何云服务供应商,只要在目标机器配置好上述任一套 API 参数即可本地运行,适用于 CI、Docker 或任意平台。
启动方式
作为 MCP 服务器(供 AI Agent 调用)
Trae / Claude Desktop 配置示例:
LangChain Agent 集成(PYTHONPATH 指向 src/):
CLI 模式
💡 先 preview 再 translate:翻译会消耗 token,默认输出到独立目录
translated_output/不会覆盖原文件。正式执行前先跑preview估一下工作量,避免白花 token。
MCP 工具
使用示例
自然语言调用(通过 Trae)
"帮我扫描一下我的 Steam 游戏里哪些有可翻译文本"
"帮我翻译 'RimWorld' 这个游戏的英文文本"
"预览一下 'Factorio' 的汉化效果,不要实际写入"
直接命令行调用
新手怎么用(一句话版)
- 先预览,不花钱:
python -m game_translator_mcp preview "游戏目录"→ 看会翻译多少条。 - 觉得量合适就翻译:
python -m game_translator_mcp translate "游戏目录" --modid mygame→ 结果输出到translated_output/,原文件一个都不动。 - 翻好了?照着下面「导入汉化」复制回游戏里,中文就生效了。
怎么把汉化「装」进游戏(导入 / 覆盖原文件教学)
本工具默认是copy 模式:只把翻译结果写到 translated_output/ 目录,绝不侵入你的原游戏文件。这样安全,但中文不会立即生效——你需要自己把汉化文件放进游戏认得到的位置。不同游戏的「位置」不一样,通常是这三种情况:
⚠️ 覆盖前请一定留备份——这是能安全撤回去的唯一办法:
如果你不确定该放哪,直接把游戏目录 + 汉化输出目录一起发给 AI,让它帮你判断文件对应关系、给出准确的复制命令 —— 因为本工具就是给 AI Agent 调用的。
需要我把这份「导入/覆盖」说明做成逐步演示(配上具体游戏的实际路径)吗?告诉我你的游戏和目录,我就演示给你看。
输出结构
核心模块
设计要点
- 智能缓存:对
{modid}::key::value做 SHA-256 哈希,相同原文只翻译一次,结果持久化到translator_cache.json - 零成本预览:
preview_translate_game先扫文件、估条目数和 token,不调 AI、不写文件,帮你决定要不要花钱翻译 - 已有汉化跳过:若输出目录中已存在相同格式的翻译文件,自动跳过,避免覆盖社区翻译
- 批量翻译:每条请求携带最多
BATCH_SIZE个条目,一次 API 调用返回全部结果,大幅降低 token 和延迟 - 供应商自适应:检测用户配置了哪个 key 就用哪个(custom > agnes > dashscope),可选 DeepSeek 做 fallback,不绑定任何一家
- 零侵入输出:默认 copy 模式生成独立输出目录,不修改原游戏文件
测试
所有测试均在 Windows + Python 3.14 环境下通过(89 tests passed,含新增 8 类明文格式用例与零成本预览 preview 用例)。
真实汉化测试
结合真实游戏文件做了端到端汉化验证(使用 agnes ai),结果已归档到 tests/reports/:
- ✅ REPO(怪兽跑图):
Menu/HUD/Game.tsv共 603 条,全部真实翻译并回写为 TSV,成功 602 条 - ✅ Portal 2:Source 引擎 VDF(UTF-16)端到端汉化,
basemodui_english.txt共 2231 条明文可翻译,回写保留 UTF-16 BOM - ✅ Biped 2:
localization_en.txt明文key=value928 条,可直接汉化 - ✅ 新增明文格式:
.csv/.properties/.po/.strings/.resx/.xliff/.rpy/.srt/.ass全部做了真实翻译与回写验证;其中.rpy/.srt/.ass采用原位 token 回填,不破坏脚本/字幕结构 - 🔍 其余游戏(Isaac / Palworld / CSGO 等):文本封装于私有资源包或仅引擎配置,详见测试报告
欢迎补充游戏库
本工具支持任意明文文本格式的游戏/模组。如果你的游戏文案以明文文件(.json / .tsv / .lang / .sii / .vdf 等)存储,欢迎通过 Issue / PR 补充游戏库,一起扩展现有解析器。
- 已完成的支持范围见 SUPPORTED_GAMES.md
- 详细测试与新增游戏接入指引见
tests/reports/ - 新格式接入步骤见下方「贡献指南」
与现有工具链的关系
贡献指南
添加对新游戏格式的支持:
- 在
parser.py中添加新的解析函数(如_parse_locres) - 注册到
_PARSERS字典 - 在
scanner.py的SUPPORTED_EXTENSIONS中添加扩展名 - 在
tests/test_parser.py中添加对应测试
许可证
MIT License — 自由使用、修改和分发。
Source: README.md at commit 3900dd0
Tools
0Version history
1- v0.2.1LatestOct 23, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts