Skip to content

feat: Add automated translation sync workflow with DeepSeek API#876

Merged
comfyui-wiki merged 5 commits intomainfrom
feat/auto-translation-sync
Apr 1, 2026
Merged

feat: Add automated translation sync workflow with DeepSeek API#876
comfyui-wiki merged 5 commits intomainfrom
feat/auto-translation-sync

Conversation

@comfyui-wiki
Copy link
Copy Markdown
Member

@comfyui-wiki comfyui-wiki commented Mar 29, 2026

Summary

  • Adds .github/workflows/translation-sync.yml — triggers when a PR with the needs-translation label is merged into main, or via manual workflow_dispatch
  • Adds .github/scripts/translate-sync.py — diff-based translation sync using DeepSeek API
  • Adds .github/scripts/translation-config.json — language config (Japanese, Simplified Chinese)

How it works

  1. On merge of a needs-translation-labeled PR, the workflow detects changed English .mdx files
  2. For each file, it uses unified diff hunk headers (`@@ -a,b +c,d @@`) to identify exactly which sections changed — language-agnostic, no heading-text matching
  3. Only changed sections are re-translated; existing translations are preserved
  4. A new branch `i18n/sync-` is created and a PR is opened for human review

Robustness features

  • Per-section error isolation with `[FALLBACK]` logging (single section failure keeps original)
  • API retry with exponential backoff (3 attempts)
  • MDX tag count validation post-translation (fallback if mismatch)
  • Frontmatter integrity check (`---` delimiter validation)
  • File-level error isolation
  • Empty API response guard
  • Fallback to full-file translation if diff parsing yields no changed sections

To add a new language

Add an entry to `.github/scripts/translation-config.json`.

Test plan

  • Dry-run tested locally against PR Screenshot update #866 commit range — correctly detected 7 English files, skipped already-synced zh files
  • Live run tested — correctly identified changed section by diff hunk line numbers, translated only the modified section
  • Create `needs-translation` label in the repo before merging

🤖 Generated with Claude Code

@mintlify
Copy link
Copy Markdown
Contributor

mintlify bot commented Mar 29, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
comfy 🟢 Ready View Preview Mar 29, 2026, 4:43 PM

comfyui-wiki and others added 5 commits April 1, 2026 11:31
- .github/workflows/translation-sync.yml: triggers on push to main,
  detects which language files are out of sync, runs translation script,
  creates a PR for review
- .github/scripts/translate-sync.py: diff-based translation — only
  translates changed sections (split by headings), skips files already
  updated in the same commit
- .github/scripts/translation-config.json: language config, easily
  extensible to add new languages

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fixes

- Use section index position instead of heading text to match sections
  between English and translated files (language-agnostic)
- Fix language dir: zh-CN → zh, snippets/zh
- Fix workflow: use step output for branch name instead of env var
- Fix workflow: use gh pr create body inline to avoid heredoc issues
- Add .env to .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace content-based index matching with proper unified diff hunk
header parsing (@@ -a,b +c,d @@). Changed line ranges in the new file
are mapped to section indices via line number overlap, making the logic
fully language-agnostic and correctly handling inserted, deleted, or
reordered sections.

Also add .env to .gitignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Per-section error isolation with [FALLBACK] logging
- API retry with exponential backoff (3 attempts)
- MDX tag count validation post-translation
- Frontmatter integrity check (--- delimiters)
- File-level error isolation
- Empty API response guard
- Fallback to full-file translation when diff yields no changed sections
- Add zh-CN to exclude_dirs in translation config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@comfyui-wiki comfyui-wiki force-pushed the feat/auto-translation-sync branch from 190cb35 to 327751f Compare April 1, 2026 04:22
@comfyui-wiki comfyui-wiki merged commit 15a52a0 into main Apr 1, 2026
5 checks passed
@github-actions github-actions bot deleted the feat/auto-translation-sync branch April 1, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant