Sync Translations #172
This file contains hidden or 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: "Sync Translations" | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Run daily at midnight | |
| workflow_dispatch: # Allow manual triggers | |
| pull_request: | |
| types: [labeled] # Trigger on PR label | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync-translations: | |
| if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'sync-translations' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Transifex CLI | |
| run: | | |
| cd /usr/local/bin | |
| sudo curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gettext | |
| pip install transifex-python sphinx-intl polib powrap | |
| - name: Sync with Transifex | |
| env: | |
| TX_TOKEN: ${{ secrets.TX_TOKEN }} | |
| run: | | |
| # Pull reviewed translations from Transifex | |
| tx pull -f -l fa --mode=reviewed | |
| # Format .po files | |
| find . -name "*.po" -exec msgcat --no-wrap {} -o {} \; | |
| - name: Format PO files | |
| run: | | |
| find . -name "*.po" -exec powrap {} \; | |
| - name: Commit and push changes | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| git config --local user.name "GitHub Action's update-translation job" | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "Update Farsi translations from Transifex" || echo "No changes to commit" | |
| git push |