Skip to content

Commit 3743ec1

Browse files
authored
Merge pull request #858 from skytin1004/Add-translation-workflow
Add Co-op Translator workflow
2 parents 81d4391 + e9ecf47 commit 3743ec1

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Co-op Translator
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
co-op-translator:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.10'
26+
27+
- name: Install Co-op Translator
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install co-op-translator
31+
32+
- name: Run Co-op Translator
33+
env:
34+
PYTHONIOENCODING: utf-8
35+
# Azure AI Service Credentials
36+
AZURE_AI_SERVICE_API_KEY: ${{ secrets.AZURE_AI_SERVICE_API_KEY }}
37+
AZURE_AI_SERVICE_ENDPOINT: ${{ secrets.AZURE_AI_SERVICE_ENDPOINT }}
38+
39+
# Azure OpenAI Credentials
40+
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
41+
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
42+
AZURE_OPENAI_MODEL_NAME: ${{ secrets.AZURE_OPENAI_MODEL_NAME }}
43+
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }}
44+
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
45+
46+
# OpenAI Credentials
47+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
48+
OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }}
49+
OPENAI_CHAT_MODEL_ID: ${{ secrets.OPENAI_CHAT_MODEL_ID }}
50+
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
51+
run: |
52+
# =====================================================================
53+
# IMPORTANT: Set your target languages here (REQUIRED CONFIGURATION)
54+
# =====================================================================
55+
# Example: Translate to Spanish, French, German. Add -y to auto-confirm.
56+
translate -l "all" -y # <--- MODIFY THIS LINE with your desired languages
57+
# translate -l "zh tw hk fr ja ko pt es de fa pl hi" -y
58+
59+
- name: Authenticate GitHub App
60+
id: generate_token
61+
uses: tibdex/github-app-token@v1
62+
with:
63+
app_id: ${{ secrets.GH_APP_ID }}
64+
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
65+
66+
- name: Create Pull Request with translations
67+
uses: peter-evans/create-pull-request@v5
68+
with:
69+
token: ${{ steps.generate_token.outputs.token }}
70+
commit-message: "🌐 Update translations via Co-op Translator"
71+
title: "🌐 Update translations via Co-op Translator"
72+
body: |
73+
This PR updates translations for recent changes merged into the `main` branch.
74+
75+
### 📋 Summary of Changes
76+
- Translated markdown content has been added under the `translations/` directory
77+
- Translated images (if applicable) have been generated in the `translated_images/` directory
78+
79+
🔁 Co-op Translator ensures that changes in links, structure, or inline elements in the original content are automatically reflected in all translated files.
80+
81+
---
82+
🌐 This pull request was automatically generated by [Co-op Translator](https://github.com/Azure/co-op-translator), powered by Azure AI.
83+
84+
branch: update-translations
85+
base: main
86+
delete-branch: true
87+
add-paths: |
88+
translations/
89+
translated_images/

0 commit comments

Comments
 (0)