Crowdin Translations Sync #17
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: Crowdin Translations Sync | |
| on: | |
| # Run on push to master to upload new source strings | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'lib/l10n/app_en.arb' | |
| # Run daily to download latest translations | |
| schedule: | |
| - cron: '0 0 * * *' # Daily at midnight UTC | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| jobs: | |
| sync-crowdin: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Crowdin push (upload source) | |
| uses: crowdin/github-action@v2 | |
| with: | |
| upload_sources: true | |
| upload_translations: false | |
| download_translations: false | |
| project_id: ${{ secrets.CROWDIN_PROJECT_ID }} | |
| token: ${{ secrets.CROWDIN_API_TOKEN }} | |
| - name: Crowdin pull (download translations) | |
| id: crowdin_pull | |
| uses: crowdin/github-action@v2 | |
| with: | |
| upload_sources: false | |
| upload_translations: false | |
| download_translations: true | |
| skip_untranslated_strings: true | |
| export_only_approved: false | |
| create_pull_request: false # Explicitly disable to avoid conflicts | |
| project_id: ${{ secrets.CROWDIN_PROJECT_ID }} | |
| token: ${{ secrets.CROWDIN_API_TOKEN }} | |
| - name: Normalize ARB locales | |
| run: | | |
| for file in lib/l10n/app_*.arb; do | |
| locale=$(basename "$file" .arb | sed 's/app_//') | |
| # Standardize @@locale to match the filename (e.g., es-ES -> es) | |
| sed -i "s/\"@@locale\": \"[^\"]*\"/\"@@locale\": \"$locale\"/g" "$file" | |
| done | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| id: cpr | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: 'chore: update and normalize translations from Crowdin' | |
| title: 'New Crowdin translations' | |
| body: 'New translations from Crowdin with normalized @@locale entries to prevent build failures.' | |
| branch: 'l10n_crowdin_action' | |
| base: 'master' | |
| - name: Enable Pull Request Automerge | |
| if: steps.cpr.outputs.pull_request-number != '' | |
| run: gh pr merge "${{ steps.cpr.outputs.pull_request-number }}" --auto --merge | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |