Translate Strings #34
This file contains 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
name: Translate Strings | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- 'resources/lang/en.json' | |
workflow_dispatch: | |
workflow_call: | |
jobs: | |
translate_and_create_pr: | |
name: Translate and create PR | |
runs-on: ${{ vars.RUNNER }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install openai | |
- name: Download translation script | |
run: wget https://raw.githubusercontent.com/ProcessMaker/processmaker/develop/.github/workflows/scripts/translate.py | |
- name: Translate changed strings to Spanish | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
OPENAI_ORG: ${{ secrets.OPENAI_ORG }} | |
run: python translate.py es | |
- name: Translate changed strings to French | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
OPENAI_ORG: ${{ secrets.OPENAI_ORG }} | |
run: python translate.py fr | |
- name: Translate changed strings to German | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
OPENAI_ORG: ${{ secrets.OPENAI_ORG }} | |
run: python translate.py de | |
- name: Remove translation script | |
run: rm -rf translate.py | |
- name: Delete existing branch if it exists | |
run: | | |
if git show-ref --quiet refs/remotes/origin/translate/changed-strings; then | |
git push origin --delete translate/changed-strings | |
fi | |
- name: Create PR for updated translated files | |
id: create_pr | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: 'Update translations for changed strings' | |
title: 'Update translations for changed strings' | |
body: 'This PR translates changed strings in en.json to Spanish, French, and German.' | |
branch: 'translate/changed-strings' | |
delete-branch: true | |
labels: 'translation, automated' | |
- name: Check if PR was created | |
if: steps.create_pr.outputs.pull-request-number == '' | |
run: echo "No changes to translations. No PR created." |