mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Apply pre- and post-processing steps to translations via GitHub Actions
Crowdin doesn't understand {%param}, which affects our ability to do QA on Crowdin directly. It does understand {param}, which is the closest neighbour.
This commit is contained in:
61
.github/workflows/download-translations.yml
vendored
Normal file
61
.github/workflows/download-translations.yml
vendored
Normal file
@@ -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 }}
|
33
.github/workflows/upload-translations.yml
vendored
Normal file
33
.github/workflows/upload-translations.yml
vendored
Normal file
@@ -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 }}
|
Reference in New Issue
Block a user