Skip to content

Implement UI language switch and i18n for legal pages #1

Implement UI language switch and i18n for legal pages

Implement UI language switch and i18n for legal pages #1

# SPDX-FileCopyrightText: 2025 PeARS Project, <community@pearsproject.org>
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Compile translations
on:
push:
branches:
- main
paths:
- 'translations/**/*.po'
pull_request:
branches:
- '*'
paths:
- 'translations/**/*.po'
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Babel
run: pip install Babel
- name: Compile .po to .mo
run: pybabel compile -d translations
- name: Check for changes
id: changes
run: |
if git diff --quiet translations/; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit compiled translations
if: steps.changes.outputs.changed == 'true' && github.event_name == 'push'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add translations/**/*.mo
git commit -m "Compile translation files (.po → .mo)"
git push
- name: Warn about outdated .mo files in PR
if: steps.changes.outputs.changed == 'true' && github.event_name == 'pull_request'
run: |
echo "::warning::The .mo files are out of date with the .po files. They will be auto-compiled on merge to main."