Skip to content

Commit 543145e

Browse files
committed
Setting up github actions for crowdin
1 parent 6909d88 commit 543145e

6 files changed

Lines changed: 252 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Create Crowdin project
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
crowdin-create:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
13+
- name: Create crowdin project
14+
uses: crowdin/github-action@v2
15+
with:
16+
command: "project add"
17+
command_args: "RPF-Project-${{ github.event.repository.name }} -l fr -l nl -l de -l hi -l it -l ja -l pt-BR -l es-419 -l uk"
18+
env:
19+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
20+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Crowdin Download Action
2+
3+
on:
4+
schedule:
5+
# Run every day at 1 AM UTC
6+
- cron: "0 1 * * *"
7+
workflow_dispatch: # Manual triggering
8+
inputs:
9+
language_code:
10+
description: 'Language code to download translations for (leave empty to download all languages)'
11+
required: false
12+
default: ''
13+
type: string
14+
15+
concurrency:
16+
group: crowdin-download
17+
cancel-in-progress: true
18+
19+
permissions: write-all
20+
21+
jobs:
22+
crowdin:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Skip if Crowdin ID missing
26+
run: |
27+
if [ -z "${{ secrets.CROWDIN_PROJECT_ID }}" ]; then
28+
echo "Skipping Crowdin sync — no project ID set."
29+
exit 0
30+
fi
31+
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
ref: master
36+
37+
- name: Download all translations from Crowdin
38+
uses: crowdin/github-action@v2
39+
with:
40+
create_pull_request: true
41+
crowdin_branch_name: master
42+
download_translations: true
43+
localization_branch_name: l10n_crowdin_translations
44+
pull_request_base_branch_name: "master"
45+
pull_request_body: "New Crowdin pull request with translations"
46+
pull_request_title: "New Crowdin translations"
47+
upload_sources: false
48+
upload_translations: false
49+
env:
50+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
51+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
if: ${{ inputs.language_code == '' }}
54+
55+
- name: Download selected translations from Crowdin
56+
uses: crowdin/github-action@v2
57+
with:
58+
create_pull_request: true
59+
crowdin_branch_name: master
60+
download_language: ${{ inputs.language_code }}
61+
download_translations: true
62+
localization_branch_name: l10n_crowdin_translations-${{ inputs.language_code }}
63+
pull_request_base_branch_name: "master"
64+
pull_request_body: "New Crowdin pull request with translations"
65+
pull_request_title: "New Crowdin translations for ${{ inputs.language_code }}"
66+
upload_sources: false
67+
upload_translations: false
68+
env:
69+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
70+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
if: ${{ inputs.language_code != '' }}
73+

.github/workflows/hide-strings.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Crowdin Hide Strings
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Crowdin Upload Action"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
crowdin-upload:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install Crowdin CLI
18+
run: |
19+
curl -L https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli.zip -o crowdin-cli.zip
20+
unzip crowdin-cli.zip -d crowdin-cli
21+
mkdir -p ~/bin
22+
mv crowdin-cli/*/crowdin ~/bin/crowdin
23+
cp crowdin-cli/*/crowdin-cli.jar ~/bin/crowdin-cli.jar
24+
chmod +x ~/bin/crowdin
25+
echo "PATH=$HOME/bin:$PATH" >> $GITHUB_ENV
26+
27+
- name: Hide matching strings
28+
run: |
29+
crowdin --version
30+
crowdin string list --verbose | grep -E -- '--- /no-print ---|--- no-print|--- print-only|hero_image images/' | awk '{print $1}' | sed 's/^#//' | grep '^[0-9]\+$'
31+
while read -r id; do
32+
crowdin string edit "$id" --hidden
33+
done
34+
env:
35+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
36+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: NTTT processing
2+
3+
on:
4+
# currently allowing manual trigger only
5+
workflow_dispatch:
6+
inputs:
7+
branch:
8+
description: 'Branch to process translations on'
9+
required: false
10+
default: 'l10n_crowdin_translations'
11+
type: string
12+
locale:
13+
description: "Locale to process translations for (e.g. fr-FR). Leave blank to run all (except en)."
14+
required: false
15+
default: ''
16+
type: string
17+
18+
permissions: write-all
19+
20+
jobs:
21+
nttt-processing:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ inputs.branch || 'l10n_crowdin_translations'}}
28+
29+
- name: Set up Python 3.11
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: '3.11.0'
33+
34+
- name: Install NTTT from GitHub repository
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install git+https://github.com/raspberrypilearning/nttt.git
38+
39+
- name: Run NTTT (single locale or all except 'en')
40+
run: |
41+
set -euo pipefail
42+
43+
LOCALE="${{ inputs.locale }}"
44+
if [[ -n "$LOCALE" ]]; then
45+
# Single-locale mode
46+
if [[ "$LOCALE" == "en" ]]; then
47+
echo "Skipping 'en' locale by design."
48+
exit 0
49+
fi
50+
51+
if [[ ! -d "$LOCALE" ]]; then
52+
echo "Locale directory '$LOCALE' does not exist at repo root."
53+
echo "Available locale dirs:"
54+
ls -1d */ 2>/dev/null | sed 's#/##' || true
55+
exit 1
56+
fi
57+
58+
echo "Processing single locale: $LOCALE"
59+
pushd "$LOCALE" >/dev/null
60+
printf "y\n" | nttt -Y YES || true
61+
popd >/dev/null
62+
else
63+
# All-locales mode (current behaviour)
64+
for lang_dir in */; do
65+
if [[ -d "$lang_dir" && "$lang_dir" != "en/" ]]; then
66+
lang_code="$(basename "$lang_dir")"
67+
echo "Processing language: $lang_code"
68+
pushd "$lang_dir" >/dev/null
69+
printf "y\n" | nttt -Y YES || true
70+
popd >/dev/null
71+
fi
72+
done
73+
fi
74+
75+
- name: Add changes to branch
76+
run: |
77+
git config --local user.email "action@github.com"
78+
git config --local user.name "GitHub Action - NTTT Processing"
79+
git add .
80+
if git diff --staged --quiet; then
81+
echo "No changes after NTTT processing"
82+
else
83+
git commit -m "Apply NTTT processing to translations"
84+
git push origin HEAD:${{ inputs.branch || 'l10n_crowdin_translations'}}
85+
fi
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Crowdin Upload Action
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
8+
paths: ["en/**/*.*"]
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
crowdin-upload:
14+
if: (github.event.pull_request.merged == true) || (github.event_name == 'workflow_dispatch')
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Make sure CROWDIN_PROJECT_ID is set
21+
run: |
22+
if [ -z "${{ secrets.CROWDIN_PROJECT_ID }}" ]; then
23+
echo "CROWDIN_PROJECT_ID is not set. Please see instructions in CROWDIN.md"
24+
exit 1
25+
fi
26+
27+
- name: Crowdin push
28+
uses: crowdin/github-action@v2
29+
with:
30+
crowdin_branch_name: master
31+
upload_sources: true
32+
upload_translations: false
33+
download_translations: false
34+
env:
35+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
36+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}

crowdin.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ preserve_hierarchy: true
66

77
files:
88
- source: /en/**/*.*
9-
ignore:
10-
- /en/**/*.mp4
119
translation: /%locale%/**/%original_file_name%
1210
ignore:
1311
- /en/**/*.pdf

0 commit comments

Comments
 (0)