Description
Background
The @intlayer/cli
package provides two commands for translation workflows that are based on LLM translations :
-
Generate translations
npx intlayer doc translate --doc-pattern ./myFile.md
This creates a translated version of your source file.
-
Review translations (with optimization)
npx intlayer doc review --doc-pattern ./myFile.md
Intended to only re-review (and possibly re-translate) the chunks that have changed, saving API costs by skipping unchanged sections.
The Problem
An optimization branch of code (around line 275 in reviewDoc.ts has been commented out. Re-enabling it:
- ✅ Works perfectly when the “base translation” file and the “to-be-reviewed” file have the same number of lines.
- ❌ Fails (produces bad formatting) when the base file translated is longer than the file under review (i.e. when lines have been removed in the source).
In other words, the current diff-based chunking logic doesn’t correctly handle cases where lines were deleted in the updated file, causing mis-aligned chunks and garbled output.
Steps to Reproduce
-
Prepare
original.md
and produce its translation:npx intlayer doc translate --doc-pattern original.md
-
Edit
original.md
to remove or reorder some lines. -
Run review:
npx intlayer doc review --doc-pattern original.md
-
Observe that the translated output is misformatted or chunks are skipped incorrectly.
Expected Behavior
-
Only the modified chunks (including those affected by line deletions) should be passed to the review/LLM step.
-
Unchanged chunks should remain exactly as in the existing translated file, preserving formatting.
-
The script should gracefully handle:
- Inserted lines
- Deleted lines
- Moved blocks
Actual Behavior
- When lines are deleted in the source, the diff-based chunk slicing falls out of sync.
- Unchanged sections are sometimes reprocessed—or worse, dropped or mangled—resulting in formatting issues.