Skip to content

Commit

Permalink
i18n: Add Crowdin config & CI
Browse files Browse the repository at this point in the history
Need to specify `languages_mapping` explicitly, because Crowdin doesn't provide a lowercase locale with underscores, as required by Minecraft.
  • Loading branch information
MattSturgeon committed Jan 18, 2024
1 parent 94c8481 commit d5ac3a6
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/crowdin-download-translations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Crowdin (Download Translations)

on:
workflow_dispatch: # Allow running manually
schedule:
# https://crontab.guru
- cron: '0 */12 * * *' # Every 12 hours

# Queue this workflow after others in the 'crowdin' group, to avoid concurrency issues.
concurrency:
group: crowdin

permissions:
contents: write
pull-requests: write

jobs:
download_translations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download to PR
uses: crowdin/github-action@v1
with:
upload_sources: false
upload_translations: false
download_translations: true
skip_untranslated_strings: true
crowdin_branch_name: ${{ github.ref_name }}

create_pull_request: true
pull_request_title: Crowdin translations for ${{ github.ref_name }}
pull_request_body: |
New pull request with translations from [Crowdin](https://crowdin.com/project/freecam).
Powered by [Crowdin's GitHub Action](https://github.com/crowdin/github-action).
pull_request_labels: enhancement, i18n
pull_request_base_branch_name: ${{ github.ref_name }}
localization_branch_name: i18n/${{ github.ref_name }}
commit_message: |
i18n: New translations from Crowdin
[skip ci]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/crowdin-upload-sources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Crowdin (Upload Sources)

on:
workflow_dispatch: # Allow running manually
push: # Run when en_us is modified on the main branch
branches:
- main
paths:
- '**/lang/en_us.json'

# Queue this workflow after others in the 'crowdin' group, to avoid concurrency issues.
concurrency:
group: crowdin

jobs:
upload_sources:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Upload Sources
uses: crowdin/github-action@v1
with:
upload_sources: true
upload_translations: false
download_translations: false
crowdin_branch_name: ${{ github.ref_name }}
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/crowdin-upload-translations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Crowdin (Upload Translations)

on:
workflow_dispatch: # Allow running manually
## (Disable automatic runs for now)
# push: # Run when a non-en_us lang file is modified on the main branch
# branches:
# - main
# paths:
# - '**/lang/*.json'
# - '!**/lang/en_us.json'

# Queue this workflow after others in the 'crowdin' group, to avoid concurrency issues.
concurrency:
group: crowdin

jobs:
upload_translations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Upload Translations
uses: crowdin/github-action@v1
with:
upload_sources: false
upload_translations: true
download_translations: false
crowdin_branch_name: ${{ github.ref_name }}
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
14 changes: 14 additions & 0 deletions crowdin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
preserve_hierarchy: true

files:
- source: '/**/lang/en_us.json'
translation: '/**/lang/%locale%.json'
languages_mapping:
locale:
# Valid keys: https://developer.crowdin.com/language-codes
# Valid values ("in-game" locale column): https://minecraft.wiki/w/Language
it: it_it
ja: ja_jp
zh-CN: zh_cn

0 comments on commit d5ac3a6

Please sign in to comment.