* Fix stale PR translation revert issue
When PR A is created before PR B but PR B merges first, the translation
workflow for PR A was reverting all of PR B's changes. This happened because
the translation workflow used PR A's working directory state (which is a
snapshot from before PR B existed) rather than applying only PR A's changes.
Root cause:
- setup_translation_branch() for new branches did:
checkout -b branch → reset --soft origin/main → reset
This kept PR's working directory which could be stale
- For incremental branches, merge_docs_json_for_incremental_update() took
the English section from PR HEAD, which was also stale for old PRs
Fix:
- For NEW branches: Create branch directly from origin/main (not from PR's
working directory). This ensures we start with the latest state including
all changes from PRs merged after this PR was created.
- For EXISTING branches: Merge main's docs.json structure with our
translations (instead of taking EN section from stale PR)
- For BOTH: Selectively checkout only the files that the PR actually changed
from PR's head, rather than bringing in the entire working directory.
This prevents overwriting files from other PRs.
Example issue (PR #593):
- PR #593 only added one file
- Translation PR #611 tried to delete 11 files and revert massive docs.json changes
- This was because it used PR #593's stale state from before other PRs merged
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix: Use PR's docs.json for finding file positions in navigation
The initial fix had a side effect: since we start from main's docs.json,
and PR's new files aren't in main's English section yet, sync_docs_json_incremental()
couldn't find where to place new files in the translation navigation.
Fix: Add `reference_sha` parameter to sync_docs_json_incremental() that loads
PR's docs.json for finding file positions, while still modifying main's
translation sections. This ensures:
1. Main's docs.json structure is preserved (no reverts)
2. New files are found in PR's docs.json
3. Translations are added at the correct positions
This also removes the unused _apply_pr_english_section_to_main() method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix EN section not updated when using reference_sha
When the translation branch starts from main, the PR's docs.json
structural changes (new file entries in EN section) were not being
incorporated. This caused the translation PR to have mismatched
navigation entries.
The fix now also updates the EN section of the working directory's
docs.json when processing added files found in the reference
docs.json (from the PR).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Also remove deleted files from EN section in stale PR scenario
When processing deleted files, the sync now also removes them from the
EN section of docs.json. This is needed when the translation branch
starts from main, which may still have the deleted file entries.
Verified with comprehensive local testing covering 10 scenarios:
- Basic stale PR, multiple files, modifications, deletions
- Nested groups, new dropdowns, mixed operations
- Backward compatibility, incremental syncs, structure changes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* Add ignore_files config to exclude specific files from translation
Adds ability to specify source language files that should not be translated:
- New `ignore_files` array in config.json
- Validation ensures paths start with source dir, have valid extension, no traversal
- Filtering applied in PRAnalyzer.categorize_files() and SyncPlanGenerator.generate_sync_plan()
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* update config
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* fix redirect language code prefixes
* rename: cn -> zh, jp -> ja
* remove hardcoded ja / zh references
* remove hardcoded 'english' references
* renamed variable names and dict keys to language agnostic names
* fix: add missing language helper methods to PRAnalyzer
- Add get_language_directory() method
- Initialize source_language and target_languages from config
- Fixes AttributeError when generating mixed PR errors
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* test: kitchen sink workflow validation v2
This PR validates the translation workflow after config-driven refactoring:
Changes:
- Add new test file: test-workflow-validation.mdx
- Modify existing file: introduction.mdx
- Update docs.json navigation
Tests:
- New file translation (add workflow)
- Existing file translation (update workflow)
- Navigation sync across languages
- Config-driven language codes (zh/ja instead of cn/jp)
- Source language abstraction (no hardcoded "English")
Expected workflow behavior:
1. Detect changes in en/ directory
2. Translate new file to zh and ja
3. Update modified file translations
4. Sync docs.json for all language sections
5. Commit translated files automatically
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update workflow paths to use zh/ja instead of cn/jp
Aligns workflow trigger paths with the zh/ja language directory rename.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Revert "fix: update workflow paths to use zh/ja instead of cn/jp"
This reverts commit 9587b7cc5d.
* Revert "test: kitchen sink workflow validation v2"
This reverts commit 4abdd69fd2.
* fix: update workflow paths in doc analyze workflow to use zh/ja instead of cn/jp
* Refactor/language codes (#240)
* test: kitchen sink workflow validation v2
This PR validates the translation workflow after config-driven refactoring:
Changes:
- Add new test file: test-workflow-validation.mdx
- Modify existing file: introduction.mdx
- Update docs.json navigation
Tests:
- New file translation (add workflow)
- Existing file translation (update workflow)
- Navigation sync across languages
- Config-driven language codes (zh/ja instead of cn/jp)
- Source language abstraction (no hardcoded "English")
Expected workflow behavior:
1. Detect changes in en/ directory
2. Translate new file to zh and ja
3. Update modified file translations
4. Sync docs.json for all language sections
5. Commit translated files automatically
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update workflow paths to use zh/ja instead of cn/jp
Aligns workflow trigger paths with the zh/ja language directory rename.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Revert "fix: update workflow paths to use zh/ja instead of cn/jp"
This reverts commit 9587b7cc5d.
* Revert "test: kitchen sink workflow validation v2"
This reverts commit 4abdd69fd2.
* fix: update workflow paths in doc analyze workflow to use zh/ja instead of cn/jp
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix: update workflow files to use 'source' instead of 'english'
After refactoring the PR analyzer to use 'source' for source language
PRs (instead of hardcoded 'english'), the workflow files need to match.
Changes:
- sync_docs_analyze.yml: pr_type == 'source' (was 'english')
- sync_docs_update.yml: PR_TYPE != 'source' check
- Updated all comments from "English" to "source language"
- Updated all pr_type values in JSON from "english" to "source"
This ensures the workflows trigger correctly with the refactored
config-driven language system.
Related: language code refactoring (cn/jp → zh/ja)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix/workflow source language references (#245)
* test: kitchen sink workflow validation v2
This PR validates the translation workflow after config-driven refactoring:
Changes:
- Add new test file: test-workflow-validation.mdx
- Modify existing file: introduction.mdx
- Update docs.json navigation
Tests:
- New file translation (add workflow)
- Existing file translation (update workflow)
- Navigation sync across languages
- Config-driven language codes (zh/ja instead of cn/jp)
- Source language abstraction (no hardcoded "English")
Expected workflow behavior:
1. Detect changes in en/ directory
2. Translate new file to zh and ja
3. Update modified file translations
4. Sync docs.json for all language sections
5. Commit translated files automatically
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update workflow paths to use zh/ja instead of cn/jp
Aligns workflow trigger paths with the zh/ja language directory rename.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Revert "fix: update workflow paths to use zh/ja instead of cn/jp"
This reverts commit 9587b7cc5d.
* Revert "test: kitchen sink workflow validation v2"
This reverts commit 4abdd69fd2.
* fix: update workflow paths in doc analyze workflow to use zh/ja instead of cn/jp
* fix: update workflow files to use 'source' instead of 'english'
After refactoring the PR analyzer to use 'source' for source language
PRs (instead of hardcoded 'english'), the workflow files need to match.
Changes:
- sync_docs_analyze.yml: pr_type == 'source' (was 'english')
- sync_docs_update.yml: PR_TYPE != 'source' check
- Updated all comments from "English" to "source language"
- Updated all pr_type values in JSON from "english" to "source"
This ensures the workflows trigger correctly with the refactored
config-driven language system.
Related: language code refactoring (cn/jp → zh/ja)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix
* fix docs.json language codes
* rename previous version docs: cn -> zh, jp -> ja
* rm duplicate redirect entires
---------
Co-authored-by: Claude <noreply@anthropic.com>
Add tools for comparing translation quality between different models
(e.g., Sonnet vs Opus) or prompt variations. Useful for evaluating
translation improvements before deploying changes.
- run_test.py: Test runner with Dify API streaming
- compare.py: Generate similarity reports between variants
- Example spec and documentation included
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>