name: Build web documentation translations on: push: branches: [develop] paths: - 'web/messages/en/*.json' - 'web/messages/en/**/*.json' - '.github/scripts/build_web_docs_i18n.py' - '.github/scripts/build_translation_cache.py' - '.github/workflows/build-web-docs-i18n.yml' 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