-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add crowdin translations download / upload task
- Loading branch information
1 parent
390d091
commit cc66e70
Showing
6 changed files
with
168 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Upload lang keys to Crowdin | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- '1.[0-9]+' | ||
- '1.[0-9]+.[0-9]+' | ||
paths: | ||
- 'src/main/resources/assets/vampirism/lang/en_us.json' | ||
- 'src/main/resources/assets/vampirismguide/lang/en_us.json' | ||
|
||
jobs: | ||
upload-translations: | ||
environment: Testing | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Java JDK | ||
uses: actions/setup-java@v3.1.0 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
cache: 'gradle' | ||
- name: Determine Crowdin branch | ||
id: get_crowdin_branch | ||
run: | | ||
output=$(./gradlew crowdinBranch) | ||
version=$(echo $output | awk -F ': ' '{print $2}') | ||
echo "crowdin_branch=$version" >> $GITHUB_OUTPUT | ||
- name: Upload translation keys | ||
uses: crowdin/github-action@v1 | ||
with: | ||
crowdin_branch_name: ${{ steps.get_crowdin_branch.outputs.crowdin_branch }} | ||
env: | ||
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }} | ||
- name: Install Crowdin CLI | ||
run: npm i -g @crowdin/cli | ||
- name: Pre-translate | ||
run: crowdin pre-translate -b ${{ steps.get_crowdin_branch.outputs.crowdin_branch }} --translate-with-perfect-match-only --translate-untranslated-only --method=tm | ||
env: | ||
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
workflow_dispatch: | ||
inputs: | ||
versionType: | ||
description: 'Version Type' | ||
required: true | ||
default: 'alpha' | ||
type: choice | ||
options: | ||
- alpha | ||
- beta | ||
- release | ||
additionalVersionInfo: | ||
description: 'Additional Version Info. Only relevant for beta versions.' | ||
required: false | ||
default: '' | ||
type: string | ||
changelog: | ||
description: 'Changelog added to Curseforge and Modrinth' | ||
required: false | ||
default: '' | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
determine-environment: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
environment: ${{ steps.get_environment.outputs.environment }} | ||
version: ${{ steps.get_environment.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Determine Environment | ||
id: get_environment | ||
run: | | ||
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||
if [[ "${{ github.event.inputs.versionType }}" == 'alpha' ]]; then | ||
echo "environment=Testing" >> $GITHUB_OUTPUT | ||
echo "version=alpha" >> $GITHUB_OUTPUT | ||
elif [[ "${{ github.event.inputs.versionType }}" == 'beta' ]]; then | ||
echo "environment=Testing" >> $GITHUB_OUTPUT | ||
echo "version=beta=${{ github.event.inputs.additionalVersionInfo }}" >> $GITHUB_OUTPUT | ||
elif [[ "${{ github.event.inputs.versionType }}" == 'release' ]]; then | ||
echo "environment=Release" >> $GITHUB_OUTPUT | ||
echo "version=release" >> $GITHUB_OUTPUT | ||
fi | ||
elif [[ ${{ github.event.ref }} =~ refs\/tags\/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-(0|[1-9]\d*)\.(0|[1-9]\d*) ]]; then | ||
echo "environment=Release" >> $GITHUB_OUTPUT | ||
echo "version=release" >> $GITHUB_OUTPUT | ||
fi | ||
determine-crowdin-branch: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
crowdin_branch: ${{ steps.get_crowdin_branch.outputs.crowdin_branch }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Java JDK | ||
uses: actions/setup-java@v3.1.0 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
cache: 'gradle' | ||
- name: Determine Crowdin branch | ||
id: get_crowdin_branch | ||
run: | | ||
output=$(./gradlew crowdinBranch) | ||
version=$(echo $output | awk -F ': ' '{print $2}') | ||
echo "crowdin_branch=$version" >> $GITHUB_OUTPUT | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: [determine-crowdin-branch, determine-environment] | ||
environment: ${{ needs.determine-environment.outputs.environment }} | ||
if: needs.determine-environment.outputs.version != '' && needs.determine-environment.outputs.environment != '' | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
cache: 'gradle' | ||
- name: Install Crowdin CLI | ||
run: npm i -g @crowdin/cli | ||
- name: Download translations | ||
run: crowdin download -b ${{ needs.determine-crowdin-branch.outputs.crowdin_branch }} | ||
env: | ||
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }} | ||
- name: Publish | ||
uses: gradle/gradle-build-action@v2.7.0 | ||
with: | ||
arguments: publishAll -PMAVEN_URL=${{ secrets.MAVEN_URL }} -PMAVEN_USER=${{ secrets.MAVEN_USER }} -PMAVEN_TOKEN=${{ secrets.MAVEN_TOKEN }} -PCURSEFORGE_API=${{ secrets.CURSEFORGE_API }} -PMODRINTH_API=${{ secrets.MODRINTH_API }} -PCHANGELOG=${{ github.event.inputs.changelog }} -P${{ needs.determine-environment.outputs.version }} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
project_id: "113663" | ||
api_token_env: CROWDIN_KEY | ||
base_path: "." | ||
base_url: "https://api.crowdin.com" | ||
|
||
preserve_hierarchy: true | ||
|
||
files: [ | ||
{ | ||
source: "src/main/resources/assets/vampirism/lang/en_us.json", | ||
translation: "src/main/resources/assets/vampirism/lang/%locale_with_underscore%.json", | ||
dest: "main_translations.json", | ||
}, | ||
{ | ||
source: "src/main/resources/assets/vampirismguide/lang/en_us.json", | ||
translation: "src/main/resources/assets/vampirismguide/lang/%locale_with_underscore%.json", | ||
dest: "guide.json", | ||
} | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,5 @@ | ||
tasks.register('downloadCrowdin') { | ||
ext { | ||
output = file('build/crowdin_raw.zip') | ||
update = file('build/crowdin.json') | ||
id = 'vampirism' | ||
} | ||
outputs.upToDateWhen { false } | ||
onlyIf { | ||
project.hasProperty('VAMPIRISM_CROWDIN_KEY') && !project.gradle.startParameter.isOffline() | ||
} | ||
tasks.register('crowdinBranch') { | ||
doLast { | ||
download { | ||
src "https://api.crowdin.com/api/project/${id}/export?key=${project.VAMPIRISM_CROWDIN_KEY}&export_translated_only&json" | ||
dest update | ||
overwrite true | ||
} | ||
if (!update.text.contains('success')) { | ||
throw new RuntimeException("Crowdin export failed, see ${update} for more info") | ||
} | ||
download { | ||
src "https://api.crowdin.com/api/project/${id}/download/all.zip?key=${project.VAMPIRISM_CROWDIN_KEY}" | ||
dest output | ||
overwrite true | ||
} | ||
} | ||
} | ||
|
||
tasks.register('crowdin', Copy) { | ||
dependsOn downloadCrowdin | ||
onlyIf { | ||
!downloadCrowdin.state.skipped | ||
} | ||
destinationDir = file('build/translations') | ||
from(zipTree(downloadCrowdin.output)) { | ||
filter { String line -> | ||
line.indexOf("\"\"") != -1 ? null : line //Filter empty translations | ||
} | ||
filteringCharset = 'UTF-8' | ||
exclude { it.isDirectory() } | ||
rename { it.toLowerCase() }//Minecraft needs it lowercase. | ||
exclude '**/*.lang' //Pre-1.13 format | ||
print("${project.main_version}.${project.major_version}") | ||
} | ||
} |
This file contains 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