mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
Create translator.yml (#9955)
* Create translator.yml
* update
* try with cc
* ci: 修改文件名translator为claude-translator
* ci(workflow): 更新Claude翻译工作流的配置和提示词
重构工作流配置,简化权限设置并优化翻译逻辑。更新提示词以提供更清晰的翻译指令和格式要求,确保翻译结果的一致性。
* ci(workflows): 更新Claude工作流配置
添加track_progress选项以跟踪代码审查进度
补充环境信息变量和注释说明
* ci(workflow): 更新翻译工作流的触发条件和gh命令参数
修改工作流触发条件,仅当issue或comment不含翻译内容时执行
更新gh命令参数以使用正确的环境变量
* Revert "ci(workflows): 更新Claude工作流配置"
This reverts commit 29f6a1dc8b.
* fix(ci): 修复GitHub Actions工作流中的条件判断和变量引用
修复工作流文件中的条件判断逻辑,添加括号确保正确执行
修复comment处理中的变量引用,使用正确的环境变量
添加注释说明Comment ID可能未定义的情况
* ci(workflow): 为翻译工作流添加并发控制
* ci(workflow): 仅协作者的issue或评论触发翻译工作流
---------
Co-authored-by: icarus <eurfelux@gmail.com>
This commit is contained in:
parent
b5632b0097
commit
71783aea21
66
.github/workflows/claude-translator.yml
vendored
Normal file
66
.github/workflows/claude-translator.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
name: English Translator
|
||||
concurrency:
|
||||
group: translator-${{ github.event.issue.number }}
|
||||
cancel-in-progress: false
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited]
|
||||
issue_comment:
|
||||
types: [created, edited]
|
||||
|
||||
jobs:
|
||||
translate:
|
||||
if: |
|
||||
(github.event_name == 'issues' && github.event.issue.author_association == 'COLLABORATOR' && !contains(github.event.issue.body, '**English Translation:**')) ||
|
||||
(github.event_name == 'issue_comment' && github.event.comment.author_association == 'COLLABORATOR' && !contains(github.event.comment.body, '**English Translation:**'))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write # 编辑issues/comments
|
||||
pull-requests: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude for translation
|
||||
uses: anthropics/claude-code-action@v1
|
||||
id: claude
|
||||
with:
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
claude_args: '--allowed-tools Bash(gh issue:*),Bash(gh api:repos/*/issues:*)'
|
||||
prompt: |
|
||||
你是一个多语言翻译助手。请完成以下任务:
|
||||
|
||||
1. 获取当前issue/comment的完整信息
|
||||
2. 智能检测内容。
|
||||
1. 如果是已经遵循格式要求翻译过的issue/comment,检查翻译内容和原始内容是否匹配。若不匹配,则重新翻译一次令其匹配,并遵循格式要求;若匹配,则跳过任务。
|
||||
2. 如果是未翻译过的issue/comment,检查其内容语言。若不是英文,则翻译成英文;若已经是英文,则跳过任务。
|
||||
3. 格式要求:
|
||||
- 标题:英文翻译(如果非英文)
|
||||
- 内容格式:
|
||||
**English Translation:**
|
||||
[英文翻译内容]
|
||||
|
||||
---
|
||||
|
||||
**Original Content:**
|
||||
[原始内容]
|
||||
|
||||
4. 使用gh工具更新:
|
||||
- 根据环境信息中的Event类型选择正确的命令:
|
||||
- 如果Event是'issues':gh issue edit [ISSUE_NUMBER] --title "[英文标题]" --body "[翻译内容 + 原始内容]"
|
||||
- 如果Event是'issue_comment':gh api -X PATCH /repos/[REPO]/issues/comments/[COMMENT_ID] -f body="[翻译内容 + 原始内容]"
|
||||
|
||||
环境信息:
|
||||
- Event: ${{ github.event_name }}
|
||||
- Issue Number: ${{ github.event.issue.number }}
|
||||
- Repository: ${{ github.repository }}
|
||||
- Comment ID: ${{ github.event.comment.id || 'N/A' }} (only available for comment events)
|
||||
|
||||
使用以下命令获取完整信息:
|
||||
gh issue view ${{ github.event.issue.number }} --json title,body,comments
|
||||
Loading…
Reference in New Issue
Block a user