Files
PocketMine-MP/.github/workflows/download-translations.yml
Dylan K. Taylor 87afd545fd Merge the Language repo into the main PM repo
the separated language repository has long been a source of inconvenience and annoyance,
particularly for PR contributors, because having to sync two PRs across different repos
for no reason adds unnecessary friction.

In addition, having the language files separate creates unnecessary requirements for
versioning and branching, which could all be avoided if the language strings were managed
directly in this repository.

This change will make it much easier to do new features that require adding new translation
strings, as well as getting rid of the inconvenience of cleaning up older strings.
Translation updates from Crowdin should also be able to be merged more quickly, since they
will have higher visibility on this repository.
2025-10-18 15:55:24 +01:00

67 lines
1.9 KiB
YAML

name: Download new translations from Crowdin
on:
schedule:
- cron: 0 21 * * * #every day at 9pm
workflow_dispatch:
jobs:
download:
name: Download translations
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- stable
- minor-next
- major-next
fail-fast: false
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
working-directory: resources/translations
run: |
sed -i -r 's/\{([A-Za-z0-9]+)\}/\{%\1\}/g' *.ini
git diff
git status
- name: Delete translation files with no translations
working-directory: resources/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 (${{ matrix.branch }})'
branch: crowdin-auto-fetch/${{ matrix.branch }}
title: 'New translations from Crowdin'
base: ${{ matrix.branch }}