Use this skill when a commit range in one Simplified Chinese language file is the source of truth, and the task is to keep only the current uncommitted changes in sibling i18n files that correspond to those real changes.
Typical requests:
*_zh_CN.js file."*_zh_CN.js file as the source of truth, then trim unrelated pending edits from other language files in the same directory."Turn a noisy set of uncommitted i18n edits into a focused diff that keeps only the changes that are semantically tied to a baseline file's real modifications.
A shell script automates steps 1-5 of the workflow below. Run it directly:
# Resolve paths relative to the repo root
SKILL_DIR="<skill-directory>"
# Auto-discover all modified sibling .js files
bash "$SKILL_DIR/trim-i18n-diffs.sh" path/to/lang_zh_CN.js abc123..HEAD
# Or pass explicit target files
bash "$SKILL_DIR/trim-i18n-diffs.sh" path/to/lang_zh_CN.js abc123..HEAD \
path/to/lang_ja.js path/to/lang_ko.js
The script will:
.js files (or use explicit targets)After the script finishes, proceed to Verify the trimmed result (step 6 below).
To verify that the remaining diff only touches relevant keys, run:
bash "$SKILL_DIR/verify-trim.sh" path/to/lang_zh_CN.js abc123..HEAD
The script exits 0 when every target file is clean and exits 1 if unexpected keys are found.
Gather these inputs before editing:
A..B*_zh_CN.jsIf the user does not say otherwise, assume the baseline file is only used for analysis and you should trim the other currently modified sibling language files in the same directory.
Run a diff for the baseline file over the requested range and determine the real changed keys.
Preferred command pattern:
git diff <range> -- <baseline-file>
Do not rely on line numbers alone. Treat these as the real changes:
When reading the patch, extract the i18n keys from changed object entries, for example lines that look like:
'reset' : '重置',
Create the smallest possible key set from the baseline diff.
Include:
foo.old and foo.newDo not include unrelated neighbors just because they share nearby line numbers.
List the currently modified sibling language files in the same directory as the baseline file and narrow to the intended scope.
Preferred command pattern:
git diff --name-only -- <baseline-dir>/*.js
git status --short
Usually this means:
all `*.js` language files in the same directory as the chosen `*_zh_CN.js`
Selection rules:
*_zh_CN.js itself unless the user explicitly asks to trim it toofoo_zh_CN.js and bar_zh_CN.js, only use the one the user named, or the one whose diff range was explicitly providedHEADFor each modified target file:
HEAD as the clean baselineHEAD content with the working tree contentThis is the important rule:
HEAD content for irrelevant keysThat means the output file should effectively be:
HEAD file contentKey-specific handling:
HEAD and in working tree, copy the working tree line back onto the HEAD structureHEAD and was intentionally removed in working tree, keep that removalDo not reorder the whole file unless the file was already reordered. Prefer minimal diffs.
After editing, verify that the remaining diff is limited to the relevant key set.
Recommended checks:
git diff --stat -- <targets>git diff -- <sample-target>The remaining hunks should only touch keys from the relevant key set. If unrelated strings like search, AI, or text mode keys remain, the trim was too broad and should be corrected.
For many sibling language files, scripting the trim is safer than manual editing. Use the provided trim-i18n-diffs.sh script when possible. If manual editing is needed, a reliable approach is:
HEADHEAD, overlaying only relevant key changes from the working treeThis approach is especially useful when many language files contain mixed relevant and irrelevant edits.
When reporting back to the user, summarize:
This skill is a strong fit for workflows like:
*_zh_CN.js<sha>..HEADWhere the goal is to keep only the still-uncommitted translation changes in sibling files that truly map to the baseline file's changed keys.