Skip to content

Commit df9d61f

Browse files
Merge pull request #19 from raspberrypilearning/draft
Prepare for translation
2 parents 7b3a3f8 + a62122e commit df9d61f

File tree

11 files changed

+258
-0
lines changed

11 files changed

+258
-0
lines changed
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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
13+
permissions: write-all
14+
15+
jobs:
16+
nttt-processing:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
ref: ${{ inputs.branch || 'l10n_crowdin_translations'}}
23+
24+
- name: Set up Python 3.11
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.11.0'
28+
29+
- name: Install NTTT from GitHub repository
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install git+https://github.com/raspberrypilearning/nttt.git
33+
34+
- name: Run NTTT on all language directories except 'en'
35+
run: |
36+
for lang_dir in */; do
37+
if [[ -d "$lang_dir" && "$lang_dir" != "en/" ]]; then
38+
lang_code=$(basename "$lang_dir")
39+
echo "Processing language: $lang_code"
40+
cd "$lang_dir"
41+
printf "y\n" | nttt -Y YES || true
42+
cd ..
43+
fi
44+
done
45+
46+
- name: Add changes to branch
47+
run: |
48+
git config --local user.email "action@github.com"
49+
git config --local user.name "GitHub Action - NTTT Processing"
50+
git add .
51+
if git diff --staged --quiet; then
52+
echo "No changes after NTTT processing"
53+
else
54+
git commit -m "Apply NTTT processing to translations"
55+
git push origin HEAD:${{ inputs.branch || 'l10n_crowdin_translations'}}
56+
fi
57+
env:
58+
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
"project_id_env": "CROWDIN_PROJECT_ID"
2+
"api_token_env": "CROWDIN_API_TOKEN"
3+
base_path: "."
4+
base_url: "https://api.crowdin.com"
5+
preserve_hierarchy: true
6+
17
files:
28
- source: /en/**/*.*
39
translation: /%locale%/**/%original_file_name%
10+
ignore:
11+
- /en/**/*.pdf
12+
- /en/**/*.mp3
13+
- /en/**/*.zip

en/step_1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<h2 class="c-project-heading--task">Print a disgusting welcome</h2>
2+
23
--- task ---
4+
35
Use <code>print()</code> to show a welcome message for your disgusting recipe card.
6+
47
--- /task ---
58

69
<h2 class="c-project-heading--explainer">Set the scene</h2>
@@ -22,8 +25,10 @@ line_numbers: true
2225
line_number_start: 1
2326
line_highlights: 1-2
2427
---
28+
2529
print('🤢 Welcome to the DISGUSTING DISHES cookbook! 🤮')
2630
print()
31+
2732
--- /code ---
2833
</div>
2934

en/step_2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<h2 class="c-project-heading--task">Add an ingredients heading</h2>
2+
23
--- task ---
4+
35
Use <code>print()</code> to add a heading and the first ingredient to your recipe card.
6+
47
--- /task ---
58

69
<h2 class="c-project-heading--explainer">Set the scene</h2>
@@ -19,8 +22,10 @@ line_numbers: true
1922
line_number_start: 3
2023
line_highlights: 3-4
2124
---
25+
2226
print('🧠 Ingredients:')
2327
print(' - 1 cup of toenail clippings 🦶')
28+
2429
--- /code ---
2530
</div>
2631

en/step_3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<h2 class="c-project-heading--task">Add more gross ingredients</h2>
2+
23
--- task ---
4+
35
Use more <code>print()</code> lines to add extra ingredients to your recipe.
6+
47
--- /task ---
58

69
<h2 class="c-project-heading--explainer">Set the scene</h2>
@@ -19,11 +22,13 @@ line_numbers: true
1922
line_number_start: 5
2023
line_highlights: 5-9
2124
---
25+
2226
print(' - 2 rotten eggs 🥚')
2327
print(' - A handful of belly button fluff 🤏')
2428
print(' - 3 eyeballs 👁️👁️👁️')
2529
print(' - Green slime to taste 🧪')
2630
print()
31+
2732
--- /code ---
2833
</div>
2934

en/step_4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<h2 class="c-project-heading--task">Add your first instructions</h2>
2+
23
--- task ---
4+
35
Use <code>print()</code> to show the first two steps for your recipe.
6+
47
--- /task ---
58

69
<h2 class="c-project-heading--explainer">Set the scene</h2>
@@ -19,9 +22,11 @@ line_numbers: true
1922
line_number_start: 10
2023
line_highlights: 10-12
2124
---
25+
2226
print('🧪 Instructions:')
2327
print('1. Mix the toenails and eggs in a dirty sock.')
2428
print('2. Sprinkle in the belly button fluff.')
29+
2530
--- /code ---
2631
</div>
2732

0 commit comments

Comments
 (0)