mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-31 16:49:07 +08:00
* refactor(i18n): 将日语和俄语迁移到translate目录 * refactor(i18n): 将日语和俄语翻译文件移动到机器翻译目录 * docs(i18n): 更新翻译目录的README说明 * ci: 添加自动国际化翻译的 GitHub Actions 工作流 * Potential fix for code scanning alert no. 48: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix(i18n): 修复国际化文件末尾缺少换行符的问题 * ci(workflow): 修改自动i18n工作流触发条件为pull_request 将触发条件从push到main分支改为在pull_request的opened、synchronize和reopened事件时触发 * ci(workflow): 更新自动i18n工作流的权限和推送配置 添加pull-requests写入权限以支持PR操作 将推送动作更新为github-push-action并改为推送至PR分支 * ci(github): 更新自动i18n工作流以支持PR分支 修改自动i18n工作流,在检出步骤中添加ref参数以支持PR分支 更新提交消息格式以包含PR编号 * ci(workflows): 更新自动i18n工作流以使用yarn 将依赖管理从npm切换到yarn,并添加corepack启用步骤 * ci(workflow): 优化自动翻译工作流的依赖安装步骤 修改依赖安装命令,使用更精确的参数避免不必要的锁定文件生成,并确保安装开发依赖 * ci(workflow): 更新i18n翻译脚本的执行方式 * ci(workflow): 移除不必要的生产环境标志以简化依赖安装 移除 yarn add 命令中的 --production=false 标志,因为在此上下文中不需要区分生产环境依赖 * ci(workflow): 更新依赖安装命令以跳过构建步骤 * fix(i18n): Auto update translations for PR #9889 * ci(workflow): 优化依赖安装步骤以减少构建时间 将直接使用yarn安装依赖改为在临时目录中通过npm安装,避免全局安装影响 * ci(i18n): 在自动翻译工作流中忽略 package.json 和 yarn.lock 的更改 重置 package.json 和 yarn.lock 的更改,避免在自动更新翻译时提交这些文件 * ci(workflow): 简化自动i18n工作流的依赖安装步骤 移除不必要的corepack启用步骤,直接使用npm安装所需依赖 * Revert "fix(i18n): Auto update translations for PR #9889" This reverts commit23a4a366e1. * ci(workflow): 将 npm 安装改为 yarn 全局安装依赖以简化命令 * ci(workflow): 将依赖安装从yarn改为npm * ci(workflow): 修改i18n工作流以隔离依赖安装 将全局依赖安装改为在临时目录中安装,避免污染全局环境 使用npx运行tsx以确保使用正确版本的依赖 * fix(i18n): Auto update translations for PR #9889 * ci(workflow): 更新自动翻译工作流配置 移除 yarn 相关配置并更新翻译脚本文件名 * fix(i18n): Auto update translations for PR #9889 * ci(workflow): 在自动翻译工作流中添加prettier格式化步骤 添加prettier及其json排序插件用于自动格式化翻译后的i18n文件,确保代码风格一致 * Revert "fix(i18n): Auto update translations for PR #9889" This reverts commit423ca8fb03. * ci(workflow): 修复自动翻译工作流中prettier路径问题 * fix(i18n): Auto update translations for PR #9889 * fix(i18n): 修正西班牙语翻译中的字幕文件字段 * ci(i18n): 添加无变更时的检查逻辑 避免在没有翻译变更时生成空提交 --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
66 lines
2.2 KiB
YAML
66 lines
2.2 KiB
YAML
name: Auto I18N
|
|
|
|
env:
|
|
API_KEY: ${{ secrets.TRANSLATE_API_KEY}}
|
|
MODEL: ${{ vars.MODEL || 'deepseek/deepseek-v3.1'}}
|
|
BASE_URL: ${{ vars.BASE_URL || 'https://api.ppinfra.com/openai'}}
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
auto-i18n:
|
|
runs-on: ubuntu-latest
|
|
name: Auto I18N
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: 🐈⬛ Checkout
|
|
uses: actions/checkout@v5
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
- name: 📦 Setting Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: 📦 Install dependencies in isolated directory
|
|
run: |
|
|
# 在临时目录安装依赖
|
|
mkdir -p /tmp/translation-deps
|
|
cd /tmp/translation-deps
|
|
echo '{"dependencies": {"openai": "^5.12.2", "cli-progress": "^3.12.0", "tsx": "^4.20.3", "prettier": "^3.5.3", "prettier-plugin-sort-json": "^4.1.1"}}' > package.json
|
|
npm install --no-package-lock
|
|
|
|
# 设置 NODE_PATH 让项目能找到这些依赖
|
|
echo "NODE_PATH=/tmp/translation-deps/node_modules" >> $GITHUB_ENV
|
|
|
|
- name: 🏃♀️ Translate
|
|
run: npx tsx scripts/auto-translate-i18n.ts
|
|
|
|
- name: 🔍 Format
|
|
run: cd /tmp/translation-deps && npx prettier --write --config /home/runner/work/cherry-studio/cherry-studio/.prettierrc /home/runner/work/cherry-studio/cherry-studio/src/renderer/src/i18n/
|
|
|
|
- name: 🔄 Commit changes
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
git add .
|
|
git reset -- package.json yarn.lock # 不提交 package.json 和 yarn.lock 的更改
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit"
|
|
else
|
|
git commit -m "fix(i18n): Auto update translations for PR #${{ github.event.pull_request.number }}"
|
|
fi
|
|
|
|
- name: 🚀 Push changes
|
|
uses: ad-m/github-push-action@master
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branch: ${{ github.event.pull_request.head.ref }}
|