Check for Crowdin Updates #107
Workflow file for this run
This file contains hidden or 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
name: Check for Crowdin Updates | |
# Not sure why yet, but uploading artefacts after creating the pull requests | |
# seems to only include a part of what should be in. | |
# As a dirty fix, we upload the artefacts first, and then make the pull request | |
on: | |
schedule: | |
- cron: '0 0 * * 1' # Every Monday at 12:00 AM UTC, which is 10:00 AM Melbourne time (AEST) | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PR_TITLE: "[Automated] Update translations from Crowdin" | |
PR_DESCRIPTION: | | |
[Automated] | |
This PR includes the latest translations from Crowdin | |
Session uses the community-driven translation platform Crowdin for localization, anyone can contribute at https://getsession.org/translate | |
PR_TARGET_BRANCH: feature/update-crowdin-translations | |
jobs: | |
fetch_translations: | |
name: Download translations from crowdin | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
cache: 'pip' # caching pip dependencies | |
- name: Install Dependencies | |
shell: bash | |
run: | | |
pip install -r ${{ github.workspace }}/scripts/crowdin/requirements.txt | |
- name: Download Translations | |
env: | |
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} | |
run: | | |
python "${{ github.workspace }}/scripts/crowdin/download_translations_from_crowdin.py" \ | |
"$CROWDIN_API_TOKEN" \ | |
618696 \ | |
"${{ github.workspace }}/raw_translations" \ | |
--glossary_id 407522 \ | |
--concept_id 36 \ | |
--skip-untranslated-strings | |
- name: Upload download artefacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: session-download | |
path: | | |
${{ github.workspace }}/raw_translations/*.xliff | |
${{ github.workspace }}/raw_translations/_non_translatable_strings.json | |
${{ github.workspace }}/raw_translations/_project_info.json | |
overwrite: true | |
if-no-files-found: warn | |
retention-days: 7 | |
build_ios: | |
name: Build iOS strings | |
runs-on: ubuntu-latest | |
needs: [fetch_translations] | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Checkout iOS | |
uses: ./scripts/actions/checkout_ios | |
- name: Setup shared | |
uses: ./scripts/actions/setup_shared | |
- name: Prepare iOS Strings | |
run: | | |
python "${{ github.workspace }}/scripts/crowdin/generate_ios_strings.py" \ | |
"${{ github.workspace }}/raw_translations" \ | |
"${{ github.workspace }}/ios/Session/Meta/Translations" \ | |
"${{ github.workspace }}/ios/SessionUIKit/Style Guide/Constants.swift" | |
- name: Upload iOS artefacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: session-ios | |
path: | | |
${{ github.workspace }}/ios/Session/Meta/Translations/Localizable.xcstrings | |
${{ github.workspace }}/ios/SessionUIKit/Style Guide/Constants.swift | |
overwrite: true | |
if-no-files-found: warn | |
retention-days: 7 | |
build_desktop: | |
name: Build Desktop strings | |
needs: [fetch_translations] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Setup shared | |
uses: ./scripts/actions/setup_shared | |
- name: Checkout Desktop | |
uses: ./scripts/actions/checkout_desktop | |
- name: Prepare Desktop Strings | |
run: | | |
python "${{ github.workspace }}/scripts/crowdin/generate_desktop_strings.py" \ | |
"${{ github.workspace }}/raw_translations" \ | |
"${{ github.workspace }}/desktop/_locales" \ | |
"${{ github.workspace }}/desktop/ts/localization/constants.ts" | |
- name: Validate strings for Desktop | |
run: cd ${{ github.workspace }}/desktop && npm install -g yarn && yarn build:locales | |
- name: Upload Desktop artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: session-desktop | |
path: | | |
${{ github.workspace }}/desktop/_locales | |
${{ github.workspace }}/desktop/ts/localization/constants.ts | |
overwrite: true | |
if-no-files-found: warn | |
retention-days: 7 | |
build_qa: | |
name: Build QA strings | |
needs: [fetch_translations] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Setup shared | |
uses: ./scripts/actions/setup_shared | |
- name: Checkout Desktop | |
uses: ./scripts/actions/checkout_desktop | |
- name: Export QA Strings (json) | |
run: | | |
python "${{ github.workspace }}/scripts/crowdin/generate_desktop_strings.py" --qa_build \ | |
"${{ github.workspace }}/raw_translations" \ | |
"${{ github.workspace }}/desktop/_locales" \ | |
"${{ github.workspace }}/desktop/ts/localization/constants.ts" | |
- name: Prepare QA strings (ts) | |
run: | | |
cd ${{ github.workspace }}/desktop/ | |
python ./tools/localization/generateLocales.py --generate-types --print-problems --print-problem-strings --print-problem-formatting-tag-strings --error-on-problems | |
cd - | |
- name: Upload QA artefacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: session-qa | |
path: | | |
${{ github.workspace }}/desktop/ts/localization/locales.ts | |
${{ github.workspace }}/desktop/ts/localization/constants.ts | |
overwrite: true | |
if-no-files-found: warn | |
retention-days: 7 | |
build_android: | |
name: Build Android strings | |
runs-on: ubuntu-latest | |
needs: [fetch_translations] | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Checkout Android | |
uses: ./scripts/actions/checkout_android | |
- name: Setup shared | |
uses: ./scripts/actions/setup_shared | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
cache: gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Prepare Android Strings | |
run: | | |
rm -rf ${{ github.workspace }}/android/app/src/main/res/values*/strings.xml | |
python "${{ github.workspace }}/scripts/crowdin/generate_android_strings.py" \ | |
"${{ github.workspace }}/raw_translations" \ | |
"${{ github.workspace }}/android/app/src/main/res" \ | |
"${{ github.workspace }}/android/app/src/main/java/org/session/libsession/utilities/NonTranslatableStringConstants.kt" | |
- name: Upload Android artefacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: session-android | |
path: | | |
${{ github.workspace }}/android/app/src/main/res/values*/strings.xml | |
${{ github.workspace }}/android/app/src/main/java/org/session/libsession/utilities/NonTranslatableStringConstants.kt | |
overwrite: true | |
if-no-files-found: warn | |
retention-days: 7 | |
- name: Validate strings for Android | |
run: cd ${{ github.workspace }}/android && ${{ github.workspace }}/android/gradlew app:mergePlayDebugResources | |
jobs_sync: | |
name: Waiting for build jobs | |
needs: [build_android, build_ios, build_desktop] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Nothing to do | |
shell: bash | |
run: echo "Nothing to do here" | |
make_android_pr: | |
name: Make Android PR | |
needs: [jobs_sync] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Checkout Android | |
uses: ./scripts/actions/checkout_android | |
- uses: actions/download-artifact@v4 | |
with: | |
name: session-android | |
# this has to be the first shared parent on the upload artefact task for Android | |
path: "${{ github.workspace }}/android/app/src/main" | |
- name: Create Android Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
path: 'android' | |
token: ${{ secrets.CROWDIN_PR_TOKEN }} | |
title: ${{ env.PR_TITLE }} | |
body: ${{ env.PR_DESCRIPTION }} | |
branch: ${{ env.PR_TARGET_BRANCH }} | |
commit-message: ${{ env.PR_TITLE }} | |
delete-branch: true | |
make_desktop_pr: | |
needs: [jobs_sync] | |
name: Make Desktop PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Checkout Desktop | |
uses: ./scripts/actions/checkout_desktop | |
- uses: actions/download-artifact@v4 | |
with: | |
name: session-desktop | |
# this has to be the first shared parent on the upload artefact task for Desktop | |
path: "${{ github.workspace }}/desktop" | |
- name: Create Desktop Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
path: 'desktop' | |
token: ${{ secrets.CROWDIN_PR_TOKEN }} | |
title: ${{ env.PR_TITLE }} | |
body: ${{ env.PR_DESCRIPTION }} | |
branch: ${{ env.PR_TARGET_BRANCH }} | |
commit-message: ${{ env.PR_TITLE }} | |
delete-branch: true | |
make_ios_pr: | |
needs: [jobs_sync] | |
name: Make iOS PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo Content | |
uses: actions/checkout@v4 | |
with: | |
path: 'scripts' | |
# don't provide a branch (ref) so it uses the default for that event | |
- name: Checkout iOS | |
uses: ./scripts/actions/checkout_ios | |
- uses: actions/download-artifact@v4 | |
with: | |
name: session-ios | |
# this has to be the first shared parent on the upload artefact task for iOS | |
path: "${{ github.workspace }}/ios" | |
- name: Create iOS Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
path: 'ios' | |
token: ${{ secrets.CROWDIN_PR_TOKEN }} | |
title: ${{ env.PR_TITLE }} | |
body: ${{ env.PR_DESCRIPTION }} | |
branch: ${{ env.PR_TARGET_BRANCH }} | |
commit-message: ${{ env.PR_TITLE }} | |
delete-branch: true | |