From 0f2bd0ffc9006db7cf37eac78d2e61497631063f Mon Sep 17 00:00:00 2001 From: sashamishcheriakova <135987917+sashamishcheriakova@users.noreply.github.com> Date: Thu, 18 Dec 2025 13:27:54 +0000 Subject: [PATCH] Prepare for translation Add workflow files, empty lines --- .github/workflows/create-crowdin-project.yml | 20 ++++++ .github/workflows/download-translations.yml | 73 ++++++++++++++++++++ .github/workflows/hide-strings.yml | 36 ++++++++++ .github/workflows/nttt-processing.yml | 58 ++++++++++++++++ .github/workflows/upload-sources.yml | 36 ++++++++++ crowdin.yml | 12 +++- en/step_1.md | 5 ++ en/step_2.md | 5 ++ en/step_3.md | 5 ++ en/step_4.md | 5 ++ en/step_5.md | 5 ++ en/step_6.md | 5 ++ 12 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/create-crowdin-project.yml create mode 100644 .github/workflows/download-translations.yml create mode 100644 .github/workflows/hide-strings.yml create mode 100644 .github/workflows/nttt-processing.yml create mode 100644 .github/workflows/upload-sources.yml diff --git a/.github/workflows/create-crowdin-project.yml b/.github/workflows/create-crowdin-project.yml new file mode 100644 index 0000000..d881f83 --- /dev/null +++ b/.github/workflows/create-crowdin-project.yml @@ -0,0 +1,20 @@ +name: Create Crowdin project + +on: + workflow_dispatch: + +jobs: + crowdin-create: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create crowdin project + uses: crowdin/github-action@v2 + with: + command: "project add" + 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" + env: + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} diff --git a/.github/workflows/download-translations.yml b/.github/workflows/download-translations.yml new file mode 100644 index 0000000..7f3b622 --- /dev/null +++ b/.github/workflows/download-translations.yml @@ -0,0 +1,73 @@ +name: Crowdin Download Action + +on: + schedule: + # Run every day at 1 AM UTC + - cron: "0 1 * * *" + workflow_dispatch: # Manual triggering + inputs: + language_code: + description: 'Language code to download translations for (leave empty to download all languages)' + required: false + default: '' + type: string + +concurrency: + group: crowdin-download + cancel-in-progress: true + +permissions: write-all + +jobs: + crowdin: + runs-on: ubuntu-latest + steps: + - name: Skip if Crowdin ID missing + run: | + if [ -z "${{ secrets.CROWDIN_PROJECT_ID }}" ]; then + echo "Skipping Crowdin sync — no project ID set." + exit 0 + fi + + - name: Checkout + uses: actions/checkout@v4 + with: + ref: master + + - name: Download all translations from Crowdin + uses: crowdin/github-action@v2 + with: + create_pull_request: true + crowdin_branch_name: master + download_translations: true + localization_branch_name: l10n_crowdin_translations + pull_request_base_branch_name: "master" + pull_request_body: "New Crowdin pull request with translations" + pull_request_title: "New Crowdin translations" + upload_sources: false + upload_translations: false + env: + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: ${{ inputs.language_code == '' }} + + - name: Download selected translations from Crowdin + uses: crowdin/github-action@v2 + with: + create_pull_request: true + crowdin_branch_name: master + download_language: ${{ inputs.language_code }} + download_translations: true + localization_branch_name: l10n_crowdin_translations-${{ inputs.language_code }} + pull_request_base_branch_name: "master" + pull_request_body: "New Crowdin pull request with translations" + pull_request_title: "New Crowdin translations for ${{ inputs.language_code }}" + upload_sources: false + upload_translations: false + env: + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: ${{ inputs.language_code != '' }} + diff --git a/.github/workflows/hide-strings.yml b/.github/workflows/hide-strings.yml new file mode 100644 index 0000000..93a8a1d --- /dev/null +++ b/.github/workflows/hide-strings.yml @@ -0,0 +1,36 @@ +name: Crowdin Hide Strings + +on: + workflow_run: + workflows: ["Crowdin Upload Action"] + types: + - completed + +jobs: + crowdin-upload: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Crowdin CLI + run: | + curl -L https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli.zip -o crowdin-cli.zip + unzip crowdin-cli.zip -d crowdin-cli + mkdir -p ~/bin + mv crowdin-cli/*/crowdin ~/bin/crowdin + cp crowdin-cli/*/crowdin-cli.jar ~/bin/crowdin-cli.jar + chmod +x ~/bin/crowdin + echo "PATH=$HOME/bin:$PATH" >> $GITHUB_ENV + + - name: Hide matching strings + run: | + crowdin --version + crowdin string list --verbose | grep -E -- '--- /no-print ---|--- no-print|--- print-only|hero_image images/' | awk '{print $1}' | sed 's/^#//' | grep '^[0-9]\+$' + while read -r id; do + crowdin string edit "$id" --hidden + done + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} diff --git a/.github/workflows/nttt-processing.yml b/.github/workflows/nttt-processing.yml new file mode 100644 index 0000000..ba35944 --- /dev/null +++ b/.github/workflows/nttt-processing.yml @@ -0,0 +1,58 @@ +name: NTTT processing + +on: + # currently allowing manual trigger only + workflow_dispatch: + inputs: + branch: + description: 'Branch to process translations on' + required: false + default: 'l10n_crowdin_translations' + type: string + +permissions: write-all + +jobs: + nttt-processing: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch || 'l10n_crowdin_translations'}} + + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: '3.11.0' + + - name: Install NTTT from GitHub repository + run: | + python -m pip install --upgrade pip + pip install git+https://github.com/raspberrypilearning/nttt.git + + - name: Run NTTT on all language directories except 'en' + run: | + for lang_dir in */; do + if [[ -d "$lang_dir" && "$lang_dir" != "en/" ]]; then + lang_code=$(basename "$lang_dir") + echo "Processing language: $lang_code" + cd "$lang_dir" + printf "y\n" | nttt -Y YES || true + cd .. + fi + done + + - name: Add changes to branch + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action - NTTT Processing" + git add . + if git diff --staged --quiet; then + echo "No changes after NTTT processing" + else + git commit -m "Apply NTTT processing to translations" + git push origin HEAD:${{ inputs.branch || 'l10n_crowdin_translations'}} + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/upload-sources.yml b/.github/workflows/upload-sources.yml new file mode 100644 index 0000000..28af698 --- /dev/null +++ b/.github/workflows/upload-sources.yml @@ -0,0 +1,36 @@ +name: Crowdin Upload Action + +on: + pull_request: + types: [closed] + branches: + - master + paths: ["en/**/*.*"] + + workflow_dispatch: + +jobs: + crowdin-upload: + if: (github.event.pull_request.merged == true) || (github.event_name == 'workflow_dispatch') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Make sure CROWDIN_PROJECT_ID is set + run: | + if [ -z "${{ secrets.CROWDIN_PROJECT_ID }}" ]; then + echo "CROWDIN_PROJECT_ID is not set. Please see instructions in CROWDIN.md" + exit 1 + fi + + - name: Crowdin push + uses: crowdin/github-action@v2 + with: + crowdin_branch_name: master + upload_sources: true + upload_translations: false + download_translations: false + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} diff --git a/crowdin.yml b/crowdin.yml index 39886fb..d37ca83 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -1,3 +1,13 @@ +"project_id_env": "CROWDIN_PROJECT_ID" +"api_token_env": "CROWDIN_API_TOKEN" +base_path: "." +base_url: "https://api.crowdin.com" +preserve_hierarchy: true + files: - - source: /en/**/.* + - source: /en/**/*.* translation: /%locale%/**/%original_file_name% + ignore: + - /en/**/*.pdf + - /en/**/*.mp3 + - /en/**/*.zip diff --git a/en/step_1.md b/en/step_1.md index 5e04f1d..46c4db8 100644 --- a/en/step_1.md +++ b/en/step_1.md @@ -1,6 +1,9 @@

Draw the snake's head

+ --- task --- + Draw a green circle in the middle of the screen to make your snake's head. + --- /task ---

Hello, snake!

@@ -17,6 +20,7 @@ line_numbers: true line_number_start: 1 line_highlights: 14, 15 --- + from p5 import * from math import sin @@ -35,6 +39,7 @@ def draw(): run() + --- /code --- diff --git a/en/step_2.md b/en/step_2.md index bb4783d..225eb7b 100644 --- a/en/step_2.md +++ b/en/step_2.md @@ -1,6 +1,9 @@

Add a body segment

+ --- task --- + Draw a second green circle behind the snake’s head to make part of its body. + --- /task ---

Stretching out

@@ -21,12 +24,14 @@ line_numbers: true line_number_start: 13 line_highlights: 16 --- + def draw(): fill('green') circle(200, 200, 50) circle(165, 200, 40) run() + --- /code --- diff --git a/en/step_3.md b/en/step_3.md index 4436fc7..b222e25 100644 --- a/en/step_3.md +++ b/en/step_3.md @@ -1,6 +1,9 @@

Make the snake move

+ --- task --- + Use a variable to make your snake slither across the screen. + --- /task ---

It’s alive!

@@ -21,6 +24,7 @@ line_numbers: true line_number_start: 13 line_highlights: 15, 17-18, 20 --- + def draw(): global x background('lightblue') @@ -29,6 +33,7 @@ def draw(): circle(x - 35, 200, 40) # body at x - 35 x += 2 # increase x by 2 + --- /code --- diff --git a/en/step_4.md b/en/step_4.md index 8c72e18..065dd3c 100644 --- a/en/step_4.md +++ b/en/step_4.md @@ -1,6 +1,9 @@

Make the snake longer

+ --- task --- + Add two more circles behind the snake to make its full body. + --- /task ---

Slither, slither...

@@ -20,6 +23,7 @@ line_numbers: true line_number_start: 13 line_highlights: 19-20 --- + def draw(): global x background('lightblue') @@ -33,6 +37,7 @@ def draw(): run() + --- /code --- diff --git a/en/step_5.md b/en/step_5.md index 773f46e..279a967 100644 --- a/en/step_5.md +++ b/en/step_5.md @@ -1,6 +1,9 @@

Add a wiggle

+ --- task --- + Use a wobbly offset to make your snake slither side to side. + --- /task ---

Make it wriggle!

@@ -23,6 +26,7 @@ line_numbers: true line_number_start: 13 line_highlights: 18, 21-23 --- + def draw(): global x background('lightblue') @@ -36,6 +40,7 @@ def draw(): circle(x - 90, 200 + offset, 30) # tail x += 2 # increase x by 2 + --- /code --- diff --git a/en/step_6.md b/en/step_6.md index 66e6f88..b65e5a4 100644 --- a/en/step_6.md +++ b/en/step_6.md @@ -1,6 +1,9 @@

Give your snake some style

+ --- task --- + Add eyes, colours, or decorations to personalise your snake. + --- /task ---

Make it yours

@@ -23,6 +26,7 @@ line_numbers: true line_number_start: 20 line_highlights: 25-27, 29-31 --- + circle(x, 200, 50) # head at x circle(x - 35, 200 + offset, 40) # body 1 circle(x - 65, 200 - offset, 35) # body 2 @@ -35,6 +39,7 @@ line_highlights: 25-27, 29-31 fill('black') circle(x + 10, 190, 5) circle(x + 25, 190, 5) + --- /code ---