實戰範例:Git 工作流程
yaku 可以透過 stdin pipe 處理 git 輸出。以下是多語言團隊常用的工作流程。
翻譯 commit 訊息
Section titled “翻譯 commit 訊息”# 最近 10 筆 commitgit log --oneline -10 | yaku --to zh-TW
# 包含完整訊息git log --format="%h %s" -10 | yaku --to zh-TW翻譯 diff
Section titled “翻譯 diff”翻譯 diff 中人類可讀的部分,同時保留 diff 標記:
git diff HEAD~1 | yaku --to zh-TWyaku 會翻譯變更的內容。Diff 標記(+、-、@@)和檔案路徑會由 LLM 的內建規則保留。
在 commit 前翻譯 commit 訊息
Section titled “在 commit 前翻譯 commit 訊息”用英文撰寫 commit 訊息,然後翻譯成中文:
# 用英文寫,翻譯成中文echo "Fixed the validation error on the login page" | yaku --to zh-TW# 修正了登入頁面的驗證錯誤
# 或用潤飾模式改善草稿中文echo "修正使用者密碼有特殊字元時不能登入的 bug" | \ yaku --mode polish --to zh-TW# 修正使用者密碼包含特殊字元時無法登入的問題翻譯 PR 描述
Section titled “翻譯 PR 描述”使用 GitHub CLI 擷取並翻譯 PR 描述:
# 翻譯 PR 內容gh pr view 42 --json body -q .body | yaku --to zh-TW
# 翻譯 PR 留言gh api repos/owner/repo/pulls/42/comments \ --jq '.[].body' | yaku --to zh-TW翻譯 release notes
Section titled “翻譯 release notes”# 翻譯最新的 release notesgh release view --json body -q .body | yaku --to zh-TW- 為 git 輸出加上
--context。 加上--context "git commit messages"能幫助 LLM 理解格式。 - 大型 diff 先用
head過濾。 避免送出巨大的 diff:git diff | head -200 | yaku --to zh-TW。 - commit 前務必檢查。 使用翻譯過的 commit 訊息前,一定要先確認內容正確。