Skip to content

Commit 2709e7a

Browse files
Merge pull request #24 from raspberrypilearning/draft
Update actions folder
2 parents 1c9e404 + 31a2b9a commit 2709e7a

5 files changed

Lines changed: 143 additions & 10 deletions

File tree

.github/workflows/download-translations.yml

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
# Run every day at 1 AM UTC
66
- cron: "0 1 * * *"
77
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
814

915
concurrency:
1016
group: crowdin-download
@@ -16,23 +22,52 @@ jobs:
1622
crowdin:
1723
runs-on: ubuntu-latest
1824
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+
1932
- name: Checkout
2033
uses: actions/checkout@v4
2134
with:
2235
ref: master
2336

24-
- name: Synchronize with Crowdin
37+
- name: Download all translations from Crowdin
2538
uses: crowdin/github-action@v2
2639
with:
27-
upload_sources: false
28-
upload_translations: false
40+
create_pull_request: true
41+
crowdin_branch_name: master
2942
download_translations: true
3043
localization_branch_name: l10n_crowdin_translations
31-
create_pull_request: true
32-
pull_request_title: "New Crowdin translations"
33-
pull_request_body: "New Crowdin pull request with translations"
3444
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
3549
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
3751
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:
3869
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Hide matching strings
2828
run: |
2929
crowdin --version
30-
crowdin string list --verbose | grep -E -- '--- /no-print ---|--- no-print|--- print-only|hero_image images/' | awk '{print $1}' | tr -d '#' |
30+
crowdin string list --verbose | grep -E -- '--- /no-print ---|--- no-print|--- print-only|hero_image images/' | awk '{print $1}' | sed 's/^#//' | grep '^[0-9]\+$'
3131
while read -r id; do
3232
crowdin string edit "$id" --hidden
3333
done
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 }}

.github/workflows/upload-sources.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,27 @@ on:
77
- master
88
paths: ["en/**/*.*"]
99

10+
workflow_dispatch:
11+
1012
jobs:
1113
crowdin-upload:
12-
if: github.event.pull_request.merged == true
14+
if: (github.event.pull_request.merged == true) || (github.event_name == 'workflow_dispatch')
1315
runs-on: ubuntu-latest
1416
steps:
1517
- name: Checkout
1618
uses: actions/checkout@v4
1719

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+
1827
- name: Crowdin push
1928
uses: crowdin/github-action@v2
2029
with:
30+
crowdin_branch_name: master
2131
upload_sources: true
2232
upload_translations: false
2333
download_translations: false

crowdin.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ files:
99
translation: /%locale%/**/%original_file_name%
1010
ignore:
1111
- /en/**/*.pdf
12-
- /en/**/*.mp3
12+
- /en/**/*.mp4
13+
- /en/**/*.zip

0 commit comments

Comments
 (0)