|
| 1 | +name: Claude Translate |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + translate-docs: |
| 9 | + # Only respond to /translate mentions from authorized users in PRs |
| 10 | + if: | |
| 11 | + ( |
| 12 | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/translate') && github.event.issue.pull_request) |
| 13 | + ) && ( |
| 14 | + github.actor == 'zbeyens' || |
| 15 | + github.actor == 'felixfeng33' |
| 16 | + ) |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: write |
| 21 | + issues: read |
| 22 | + id-token: write |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + # Fetch all history to allow the action to determine changes |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Translate Documentation |
| 31 | + uses: grll/claude-code-action@beta |
| 32 | + with: |
| 33 | + use_oauth: true |
| 34 | + claude_access_token: ${{ secrets.CLAUDE_ACCESS_TOKEN }} |
| 35 | + claude_refresh_token: ${{ secrets.CLAUDE_REFRESH_TOKEN }} |
| 36 | + claude_expires_at: ${{ secrets.CLAUDE_EXPIRES_AT }} |
| 37 | + timeout_minutes: '60' |
| 38 | + direct_prompt: | |
| 39 | + You are a professional translator. Your task is to synchronize MDX documentation from English to Chinese (`.cn.mdx`) based on the changes in this pull request. |
| 40 | +
|
| 41 | + Please follow these guidelines, referencing `.claude/commands/translate.md`: |
| 42 | +
|
| 43 | + **Primary Task:** |
| 44 | + 1. Analyze the changed files in this PR. |
| 45 | + 2. For every English file (`<name>.mdx`) that has been modified, you must update its corresponding Chinese translation (`<name>.cn.mdx`). |
| 46 | + 3. If a `*.cn.mdx` file doesn't exist for a modified `*.mdx` file, create it. |
| 47 | +
|
| 48 | + **Translation Rules:** |
| 49 | + - **Preserve Structure:** Keep all Markdown formatting, code blocks, and JSX component tags (e.g., `<APIItem>`) exactly as they are. |
| 50 | + - **Translate Text Only:** Only translate the narrative text content. |
| 51 | + - **Do Not Translate Code:** Do not translate anything inside code blocks, variable names, or function names. |
| 52 | + - **Do Not Translate Component Names:** React component names like `<CodeBlock>` or `<APIItem>` must remain in English. |
| 53 | +
|
| 54 | + **Example from `.claude/commands/translate.md`:** |
| 55 | +
|
| 56 | + *Original English:* |
| 57 | + ```mdx |
| 58 | + <APIItem name="extendApi" type="function"> |
| 59 | + xxxx content |
| 60 | + </APIItem> |
| 61 | + ``` |
| 62 | +
|
| 63 | + *Correct Chinese Translation:* |
| 64 | + ```mdx |
| 65 | + <APIItem name="extendApi" type="function"> |
| 66 | + xxxx 内容 |
| 67 | + </APIItem> |
| 68 | + ``` |
| 69 | +
|
| 70 | + Please review the PR's changes and apply the translations to the `.cn.mdx` files. |
0 commit comments