diff --git a/.github/workflows/download-translations.yml b/.github/workflows/download-translations.yml new file mode 100644 index 000000000..5b70a61b0 --- /dev/null +++ b/.github/workflows/download-translations.yml @@ -0,0 +1,61 @@ +name: Download new translations from Crowdin + +on: + schedule: + - cron: 0 21 * * * #every day at 9pm + workflow_dispatch: + push: + +jobs: + download: + name: Download translations + runs-on: ubuntu-latest + + strategy: + matrix: + branch: [ stable ] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + + - name: Download translations + uses: crowdin/github-action@v2 + with: + upload_sources: false + upload_translations: false + download_translations: true + create_pull_request: false + push_translations: false + export_only_approved: true #irrespective of project config, only accept approved translations here + crowdin_branch_name: ${{ matrix.branch }} + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + - name: Post-process placeholders back into PocketMine format + run: | + sed -i -r 's/\{([A-Za-z\d]+)\}/\{%\1\}/g' *.ini + git diff + git status + + - name: Delete translation files with no translations + run: | + for file in *.ini; do + if grep -q -P '^[A-Za-z0-9_\-\.]+=' $file; then + echo "Not empty: $file" + else + echo "Deleting empty file: $file" + rm "$file" + fi + done + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + add-paths: '*.ini' + commit-message: 'New translations from Crowdin' + branch: crowdin-auto-fetch/${{ matrix.branch }} + title: 'New translations from Crowdin' + base: ${{ matrix.branch }} diff --git a/.github/workflows/upload-translations.yml b/.github/workflows/upload-translations.yml new file mode 100644 index 000000000..fc8e7698d --- /dev/null +++ b/.github/workflows/upload-translations.yml @@ -0,0 +1,33 @@ +name: Upload translations to Crowdin + +on: + push: + paths: + - eng.ini + workflow_dispatch: + +jobs: + upload: + name: Upload translations + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - name: Preprocess eng.ini placeholders so Crowdin can understand them + run: | + sed -i -r 's/\{%([A-Za-z0-9]+)\}/\{\1\}/g' eng.ini + cat eng.ini + + - name: Upload eng.ini to Crowdin + uses: crowdin/github-action@v2 + with: + upload_sources: true + upload_translations: false + download_translations: false + create_pull_request: false + crowdin_branch_name: ${{ github.ref_name }} + env: + GITHUB_TOKEN: ${{ github.token }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}