Files
ProxMenux/.github/workflows/build-web-docs-i18n.yml
T
MacRimi f8cabb4700 Check translation contracts offline, add Swedish to the installer and enable the website languages
- Offline checks for terminal and website catalogs reject translations that change commands, paths, identifiers or placeholders
- Terminal and documentation texts that broke those contracts are corrected in every language
- Swedish can be chosen in the stable and beta installers
- The website routes, language switcher and exported pages cover the eight languages, with the shared website texts in each of them
- Website documentation translations are generated only when requested
- From PR #475 by @jcastro
2026-10-18 12:58:25 +02:00

115 lines
3.6 KiB
YAML

name: Build web documentation translations
on:
# Source and locale corrections are reviewed together. An automatic run
# would treat the changed English fingerprints as stale translations and
# overwrite those reviewed locale strings with provider output.
workflow_dispatch:
inputs:
languages:
description: 'Comma-separated locales'
default: 'es,de,fr,it,pt,sk,sv'
section:
description: 'File or directory below web/messages/en'
default: '.'
max_files:
description: 'Maximum pending files per locale; 0 means all'
default: '0'
refresh:
description: 'Overwrite existing translations in the selected scope'
type: boolean
default: false
dry_run:
description: 'Report pending coverage without writing files'
type: boolean
default: false
concurrency:
group: build-web-docs-i18n-${{ github.ref }}
cancel-in-progress: false
jobs:
translate:
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 120
steps:
- name: Checkout develop
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install translation provider
run: |
python -m pip install --upgrade pip
pip install 'googletrans==4.0.0-rc1' 'httpx==0.13.3' 'httpcore==0.9.1' 'h11==0.9.0'
- name: Build missing translations
shell: bash
run: |
LANGUAGES="${{ github.event.inputs.languages }}"
LANGUAGES="${LANGUAGES:-es,de,fr,it,pt,sk,sv}"
SECTION="${{ github.event.inputs.section }}"
SECTION="${SECTION:-.}"
MAX_FILES="${{ github.event.inputs.max_files }}"
MAX_FILES="${MAX_FILES:-0}"
EXTRA_ARGS=()
if [[ "${{ github.event.inputs.refresh }}" == "true" ]]; then
EXTRA_ARGS+=(--refresh)
fi
if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
EXTRA_ARGS+=(--dry-run)
fi
python .github/scripts/build_web_docs_i18n.py \
--source-dir web/messages/en \
--messages-dir web/messages \
--languages "$LANGUAGES" \
--section "$SECTION" \
--max-files "$MAX_FILES" \
--provider googletrans \
--workers 4 \
"${EXTRA_ARGS[@]}"
- name: Validate catalogs
run: |
python .github/scripts/build_web_docs_i18n.py \
--source-dir web/messages/en \
--messages-dir web/messages \
--languages "${{ github.event.inputs.languages || 'es,de,fr,it,pt,sk,sv' }}" \
--check
- name: Commit and push changes
if: ${{ github.event.inputs.dry_run != 'true' }}
shell: bash
run: |
if git diff --quiet -- web/messages/; then
echo "No documentation translations changed."
exit 0
fi
git config user.name "ProxMenuxBot"
git config user.email "bot@proxmenux.local"
git add web/messages/
git commit -m "docs(i18n): update documentation translations"
for attempt in 1 2 3 4 5; do
git fetch origin develop
if git rebase origin/develop && git push origin develop; then
exit 0
fi
git rebase --abort 2>/dev/null || true
sleep $((attempt * 3))
done
exit 1