Synchronize document changes from one language to another. When the user edits documents in one language directory and wants to sync the changes to the corresponding directory in another language, use git commands to find the exact changes, then translate and apply them to the target directory. Use this skill when the user says "sync translation", "sync doc", "同步翻译", "同步文档", "翻译文档变更".
Use git commands to find changed files in the user-specified source directory.
Always pipe git output through | tail -xxx to force terminal output and prevent git from opening vi/vim interactively.
Check in this priority order:
# 1. Unstaged changes (highest priority)
git diff --name-only -- <source-dir> | tail -50
# 2. Staged changes
git diff --cached --name-only -- <source-dir> | tail -50
# 3. Latest commit (fallback if no uncommitted changes)
git diff HEAD~1 --name-only -- <source-dir> | tail -50
Use unstaged changes first, then staged, then fall back to the latest commit only when there are no uncommitted changes at all.
For each changed file, retrieve the detailed diff:
# Unstaged diff for a specific file
git diff -- <file-path> | tail -300
# Staged diff for a specific file
git diff --cached -- <file-path> | tail -300
# Latest commit diff for a specific file
git diff HEAD~1 -- <file-path> | tail -300
Analyze the diff to understand:
Infer the target file path from the source file path and the target directory provided by the user. For example:
docs/user-manuals/cloneset.mdi18n/zh/docusaurus-plugin-content-docs/current/i18n/zh/docusaurus-plugin-content-docs/current/user-manuals/cloneset.mdRead the target file with read_file to understand its current content and locate the corresponding sections.
Based on the diff, update the target file:
Translation principles:
Hyperlink handling (CRITICAL):
foo/doc.md contains a link [text](example/test.md), the target file bar/doc.md must also use [text](example/test.md) to point to bar/example/test.mdhttps://github.com/example/test.md remains unchanged)After processing all changed files, summarize: