实战范例:Git 工作流程
yaku 可以通过 stdin 管道处理 git 输出。以下是多语言团队常用的工作流程。
翻译 commit 信息
Section titled “翻译 commit 信息”# 最近 10 条 commitgit log --oneline -10 | yaku --to zh-CN
# 包含完整信息git log --format="%h %s" -10 | yaku --to zh-CN翻译 diff
Section titled “翻译 diff”翻译 diff 中人类可读的部分,同时保留 diff 标记:
git diff HEAD~1 | yaku --to zh-CNyaku 会翻译变更的内容。Diff 标记(+、-、@@)和文件路径会由 LLM 的内置规则保留。
在 commit 前翻译 commit 信息
Section titled “在 commit 前翻译 commit 信息”用英文撰写 commit 信息,然后翻译成中文:
# 用英文写,翻译成中文echo "Fixed the validation error on the login page" | yaku --to zh-CN# 修复了登录页面的验证错误
# 或用润色模式改善草稿中文echo "修复用户密码有特殊字符时不能登录的 bug" | \ yaku --mode polish --to zh-CN# 修复用户密码包含特殊字符时无法登录的问题翻译 PR 描述
Section titled “翻译 PR 描述”使用 GitHub CLI 获取并翻译 PR 描述:
# 翻译 PR 内容gh pr view 42 --json body -q .body | yaku --to zh-CN
# 翻译 PR 评论gh api repos/owner/repo/pulls/42/comments \ --jq '.[].body' | yaku --to zh-CN翻译 release notes
Section titled “翻译 release notes”# 翻译最新的 release notesgh release view --json body -q .body | yaku --to zh-CN- 为 git 输出加上
--context。 加上--context "git commit messages"能帮助 LLM 理解格式。 - 大型 diff 先用
head过滤。 避免发送巨大的 diff:git diff | head -200 | yaku --to zh-CN。 - commit 前务必检查。 使用翻译过的 commit 信息前,一定要先确认内容正确。