Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork225
ci: Add Claude-powered translation and review workflows for Python docs#1209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
josix wants to merge1 commit into3.14Choose a base branch fromfeat/LLM-auto-translation
base:3.14
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Draft
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion.claude/skills/validate-translation/SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions.github/workflows/claude-review.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: claude-review-translation | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
| paths: | ||
| - "**/*.po" | ||
| jobs: | ||
| review: | ||
| # Only run on the upstream repo, skip forks | ||
| if: >- | ||
| github.repository == 'python/python-docs-zh-tw' | ||
| && !contains(github.event.pull_request.labels.*.name, 'sync-cpython') | ||
| && github.event.pull_request.head.ref != 'cron/sync/3.14' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install gettext | ||
| run: sudo apt-get install -y gettext | ||
| - uses: anthropics/claude-code-action@v1 | ||
| timeout-minutes: 10 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| github_token: ${{ github.token }} | ||
| claude_args: >- | ||
| --max-turns 5 | ||
| --allowedTools "Read,Bash(gh pr diff:*),Bash(grep:*),Bash(msgattrib:*),Bash(msgfmt:*)" | ||
| prompt: | | ||
| Review the changed PO files in this pull request for translation quality. | ||
| Follow the validate-translation and check-terminology skills for review criteria. | ||
| Steps: | ||
| 1. Run `gh pr diff ${{ github.event.pull_request.number }}` to identify changed PO files | ||
| 2. Read each changed file and review translated entries per the skill checklists | ||
| 3. Run `msgfmt --check` on each changed file to validate | ||
| 4. Post a concise review comment grouping issues by category | ||
| 5. If no issues found, post a short approval comment |
106 changes: 106 additions & 0 deletions.github/workflows/claude-translate-sync.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| name: claude-translate-sync | ||
| on: | ||
| workflow_run: | ||
| workflows: ["python-3.14-sync-with-cpython"] | ||
| types: [completed] | ||
| workflow_dispatch: | ||
| concurrency: | ||
| group: claude-translate-sync | ||
| cancel-in-progress: false | ||
| jobs: | ||
| translate: | ||
| # Only run when sync workflow succeeded (or on manual dispatch) | ||
| if: >- | ||
| github.repository == 'python/python-docs-zh-tw' | ||
| && (github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success') | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/create-github-app-token@v2 | ||
| id: app-token | ||
| with: | ||
| app-id: ${{ secrets.APP_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| - name: Find sync PR | ||
| id: find-pr | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| run: | | ||
| PR_NUMBER=$(gh pr list \ | ||
| --repo "${{ github.repository }}" \ | ||
| --head "cron/sync/3.14" \ | ||
| --state open \ | ||
| --json number \ | ||
| --jq '.[0].number // empty') | ||
| if [ -z "$PR_NUMBER" ]; then | ||
| echo "No open sync PR found on cron/sync/3.14" | ||
| echo "skip=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | ||
| echo "skip=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| - name: Checkout sync branch | ||
| if: steps.find-pr.outputs.skip != 'true' | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: cron/sync/3.14 | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| fetch-depth: 0 | ||
| - name: Configure git | ||
| if: steps.find-pr.outputs.skip != 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| - name: Install gettext | ||
| if: steps.find-pr.outputs.skip != 'true' | ||
| run: sudo apt-get install -y gettext | ||
| - name: Install uv | ||
| if: steps.find-pr.outputs.skip != 'true' | ||
| uses: astral-sh/setup-uv@v7 | ||
| - name: Run Claude to translate | ||
| if: steps.find-pr.outputs.skip != 'true' | ||
| uses: anthropics/claude-code-action@v1 | ||
| timeout-minutes: 30 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| claude_args: >- | ||
| --max-turns 20 | ||
| --allowedTools "Read,Edit,Write,Bash(git:*),Bash(grep:*),Bash(msgattrib:*),Bash(msgfmt:*),Bash(msgcat:*),Bash(uvx:*),Bash(gh:*)" | ||
| track_progress: true | ||
| prompt: | | ||
| You are working on the CPython sync PR #${{ steps.find-pr.outputs.pr_number }} | ||
| on the `cron/sync/3.14` branch. | ||
| Your task: translate fuzzy and untranslated entries in changed PO files. | ||
| Follow the translate-po skill for translation rules and fuzzy resolution. | ||
| Steps: | ||
| 1. Find changed PO files: `git diff --name-only origin/3.14...HEAD -- '*.po'` | ||
| 2. For each file, use `msgattrib --only-fuzzy` and `msgattrib --only-untranslated` to find entries | ||
| 3. Prioritize fuzzy entries first, then untranslated (use translate-po skill) | ||
| 4. After editing, run `uvx powrap <file>` and `msgfmt --check <file>` | ||
| 5. Commit and push: | ||
| ``` | ||
| git add <changed .po files> | ||
| git commit -m "Translate fuzzy and untranslated entries from sync" | ||
| git push origin cron/sync/3.14 | ||
| ``` | ||
| 6. Post a summary comment on PR #${{ steps.find-pr.outputs.pr_number }} with: | ||
| - Fuzzy entries fixed count | ||
| - New translations added count | ||
| - Files modified | ||
| - Entries skipped (if any, with reasons) | ||
| Use: `gh pr comment ${{ steps.find-pr.outputs.pr_number }} --body "<summary>"` | ||
| If no entries need work, post a short "nothing to translate" comment and skip commit/push. |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.