Skip to content

Crowdin Download Translations #1299

Crowdin Download Translations

Crowdin Download Translations #1299

name: Crowdin Download Translations
on:
workflow_dispatch:
schedule:
- cron: "0 */6 * * *"
jobs:
download:
environment: "prod"
name: Synchronize with Crowdin
runs-on: ubuntu-latest
env:
UPDATE_BRANCH: ci/update-locale
BASE_BRANCH: master
steps:
- name: Setup Node
uses: actions/setup-node@v4.0.0
with:
node-version: 18
- name: Install Dependencies
run: |
yarn global add i18next-parser
- name: Checkout
uses: actions/checkout@v4
- name: Change branch to the update branch
id: commits
run: |
git pull
echo "::set-output name=base::$(git rev-parse origin/${{ env.BASE_BRANCH }})"
git rev-parse --quiet origin/${{ env.UPDATE_BRANCH }} || git branch ${{ env.UPDATE_BRANCH }}
git checkout ${{ env.UPDATE_BRANCH }}
echo "::set-output name=update::$(git rev-parse ${{ env.UPDATE_BRANCH }}~)"
- name: Use the base branch instead
if: ${{ steps.commits.outputs.base != steps.commits.outputs.update }}
run: |
git checkout ${{ env.BASE_BRANCH }}
- name: Download Crowdin Translations
uses: crowdin/github-action@v1
with:
download_translations: true
upload_sources: false
upload_translations: false
create_pull_request: false
push_translations: false
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Organize translations
run: |
sudo chown -R $(id -u):$(id -g) packages/**/locales/*
sudo chown -R $(id -u):$(id -g) packages/twitch/**/locales/*
i18next -c 'services/crowdin/src/i18next-parser.config.js'
- name: Count lines
id: count
run: |
echo "::set-output name=lines::$(git status --porcelain | wc -l)"
- name: Create Pull Request
id: cpr
if: ${{ steps.count.outputs.lines != '0' }}
uses: peter-evans/create-pull-request@v5.0.2
with:
title: "[CI] New Crowdin Translations"
body: The latest approved translations from Crowdin
base: ${{ env.BASE_BRANCH }}
branch: ${{ env.UPDATE_BRANCH }}
commit-message: 💅 i18n update from crowdin
delete-branch: true
add-paths: |
packages/**/locales/*
packages/twitch/**/locales/*