feat: add in workflows for uploading source and downloading translations from crowdin
This commit is contained in:
parent
02d7b831f2
commit
79af483ccc
10 changed files with 118 additions and 4 deletions
42
.github/workflows/crowdin-sync.yml
vendored
Normal file
42
.github/workflows/crowdin-sync.yml
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
name: Crowdin Sync
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
synchronize-with-crowdin:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install gettext
|
||||
run: sudo apt-get install -y gettext
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 8
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Generate translations.pot
|
||||
run: ./gradlew generatePots
|
||||
|
||||
- name: Deduplicate translations.pot
|
||||
run: msguniq -o build/gettext/launcher.pot build/gettext/translations.pot
|
||||
|
||||
- name: Upload source to crowdin
|
||||
uses: crowdin/github-action@1.4.10
|
||||
with:
|
||||
upload_sources: true
|
||||
upload_translations: false
|
||||
download_translations: false
|
||||
push_translations: false
|
||||
upload_sources_args: '--dest=launcher.pot'
|
||||
source: build/gettext/launcher.pot
|
||||
translation: /src/main/resources/assets/lang/%locale%.po
|
||||
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
30
.github/workflows/download-translations.yml
vendored
Normal file
30
.github/workflows/download-translations.yml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
name: Download Translations
|
||||
|
||||
on: [workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
download-translations:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download translations from crowdin
|
||||
uses: crowdin/github-action@1.4.10
|
||||
with:
|
||||
upload_sources: false
|
||||
upload_translations: false
|
||||
download_translations: true
|
||||
skip_untranslated_strings: true
|
||||
skip_untranslated_files: true
|
||||
export_only_approved: true
|
||||
push_translations: false
|
||||
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Commit changed files
|
||||
uses: EndBug/add-and-commit@v7.0.0
|
||||
with:
|
||||
add: 'packaging/aur/'
|
||||
message: 'chore: update translations'
|
14
README.md
14
README.md
|
@ -234,20 +234,28 @@ start translating.
|
|||
|
||||
### Updating the template file
|
||||
|
||||
Every push to master will automatically add any new strings that need translating via GitHub actions.
|
||||
|
||||
#### Manual Steps
|
||||
|
||||
If new strings are added to the launcher, the template file will need to be updated in order to take into account the
|
||||
new strings.
|
||||
|
||||
In order to do this, run `./gradlew generatePots` which will scan the source files and create a
|
||||
`build/gettext/translations.pot` file.
|
||||
|
||||
Note that out of the box, this will not generate in the correct format. The file should be opened with
|
||||
[POEdit](https://poedit.net/), which will automatically fix the file, which then you can save to `translations.pot` in
|
||||
the root directory.
|
||||
Note that out of the box, this will not generate in the correct format. You must run the `deduplicateTranslations` script in
|
||||
the `scripts/deduplicateTranslations` folder which will use Docker to fix the `translations.pot` file.
|
||||
|
||||
This file can then be uploaded to Crowdin by ATLauncher staff to give access to the translators.
|
||||
|
||||
### Adding new languages from Crowdin
|
||||
|
||||
Running [this action](https://github.com/ATLauncher/ATLauncher/actions/workflows/download-translations.yml) will
|
||||
download all approved translations strings and make a commit to master with then changed language files.
|
||||
|
||||
#### Manual Steps
|
||||
|
||||
Once a language has been translated enough to add support to the launcher (or update support) there's a few steps we
|
||||
need to take.
|
||||
|
||||
|
|
|
@ -4,9 +4,15 @@ import java.util.stream.Collectors
|
|||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
content {
|
||||
includeGroup "com.github.RyanTheAllmighty.gettext"
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.mini2Dx:gettext-gradle-plugin:1.10.4'
|
||||
classpath 'com.github.RyanTheAllmighty.gettext:gettext-gradle-plugin:aab5c30bf8'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
name=ATLauncher
|
||||
org.gradle.jvmargs=-Xms128m -Xmx1024m
|
||||
|
|
1
scripts/deduplicateTranslations/.gitignore
vendored
Normal file
1
scripts/deduplicateTranslations/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
out
|
10
scripts/deduplicateTranslations/Dockerfile
Normal file
10
scripts/deduplicateTranslations/Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
|||
FROM alpine
|
||||
|
||||
RUN apk add gettext \
|
||||
&& mkdir -p /deduplicateTranslations/out
|
||||
|
||||
WORKDIR /deduplicateTranslations
|
||||
|
||||
ADD in /deduplicateTranslations/in
|
||||
|
||||
RUN msguniq -o /deduplicateTranslations/out/translations.pot in/translations.pot
|
|
@ -0,0 +1,8 @@
|
|||
copy ..\..\build\gettext\translations.pot in\translations.pot
|
||||
|
||||
docker build -t atlauncher/deduplicatetranslations .
|
||||
FOR /F "tokens=* USEBACKQ" %%F IN (`docker create -t atlauncher/deduplicatetranslations`) DO (
|
||||
SET IMAGE_ID=%%F
|
||||
)
|
||||
|
||||
docker cp %IMAGE_ID%:/deduplicateTranslations/out/translations.pot ./out/translations.pot
|
|
@ -0,0 +1,6 @@
|
|||
cp ../../build/gettext/translations.pot in/translations.pot
|
||||
|
||||
docker build -t atlauncher/deduplicatetranslations .
|
||||
IMAGE_ID=`docker create -t atlauncher/deduplicatetranslations .`
|
||||
|
||||
docker cp ${IMAGE_ID}:/deduplicateTranslations/out/translations.pot ./out/translations.pot
|
2
scripts/deduplicateTranslations/in/.gitignore
vendored
Normal file
2
scripts/deduplicateTranslations/in/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
Loading…
Reference in a new issue