name: "π Translate catalogs"
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
paths:
- "docs/**"
- "locale/**"
- "meta/languages.yml"
- "roles/**"
- "utils/i18n/**"
concurrency:
group: translate-${{ github.repository }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
languages:
name: π£οΈ Resolve machine-translatable languages
if: vars.CI_ENABLE_AUTO_TRANSLATIONS == 'true' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-26.04
outputs:
codes: ${{ steps.codes.outputs.codes }}
steps:
- name: β¬οΈ Checkout
uses: actions/checkout@v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: π§ Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: π¦ Install i18n dependencies
run: bash scripts/github/i18n/install_python.sh
- name: π£οΈ Resolve languages
id: codes
run: bash scripts/github/i18n/languages.sh
extract:
name: π Extract catalogs
if: vars.CI_ENABLE_AUTO_TRANSLATIONS == 'true' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-26.04
timeout-minutes: 60
steps:
- name: β¬οΈ Checkout
uses: actions/checkout@v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: π§ Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: π¦ Install i18n dependencies
run: bash scripts/github/i18n/install_python.sh
- name: π Merge the source strings into every catalog
run: bash scripts/github/i18n/extract.sh
- name: β¬οΈ Upload catalogs
uses: actions/upload-artifact@v7.0.1
with:
name: i18n-catalogs
path: locale
retention-days: 1
translate:
name: π Translate ${{ matrix.code }}
needs:
- languages
- extract
runs-on: ubuntu-26.04
timeout-minutes: 340
strategy:
fail-fast: false
matrix:
code: ${{ fromJSON(needs.languages.outputs.codes) }}
steps:
- name: β¬οΈ Checkout
uses: actions/checkout@v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: π§ Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: π¦ Install i18n dependencies
run: bash scripts/github/i18n/install_python.sh
- name: β¬οΈ Download catalogs
uses: actions/download-artifact@v8
with:
name: i18n-catalogs
path: locale
- name: π Translate the missing and outdated entries
run: bash scripts/github/i18n/translate.sh "${{ matrix.code }}"
- name: π Check for changes
id: diff
run: bash scripts/github/resolve/check_git_changes.sh "locale/${{ matrix.code }}"
- name: βοΈ Generate app token
if: steps.diff.outputs.changed == 'true'
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.BOT_APP_CLIENT_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
- name: π Open PR for the translated catalogs
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
UPDATE_BRANCH_PREFIX: translate/pr-${{ github.event.pull_request.number }}-${{ matrix.code }}
UPDATE_COMMIT_MESSAGE: "i18n(${{ matrix.code }}): machine-translate the new and outdated entries"
UPDATE_PR_TITLE: "i18n(${{ matrix.code }}): machine-translate the new and outdated entries"
UPDATE_PR_BODY: "Machine translation of the entries #${{ github.event.pull_request.number }} left empty or fuzzy in `locale/${{ matrix.code }}`. Produced by LibreTranslate; review before merging."
UPDATE_BASE_BRANCH: ${{ github.event.pull_request.head.ref }}
run: bash scripts/github/update/open/pr.sh "locale/${{ matrix.code }}"