Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/translations-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: translations-download

# Pulls the configured languages from Crowdin and opens (or refreshes) a
# pull request with whatever changed. New languages are added to
# i18n.config.mjs first; this only updates the ones listed there.
on:
schedule:
# Monday mornings UTC, after crowdin-reports has run at 5am. The repos
# share one Crowdin token, so each starts at a different minute.
- cron: "30 6 * * 1"
workflow_dispatch:

concurrency:
group: translations-download
cancel-in-progress: false

env:
# renovate: datasource=npm depName=npm
NPM_VERSION: "11"

jobs:
download:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 24
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm install -g npm@${{ env.NPM_VERSION }} --registry=https://registry.npmjs.org
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: microbit-foundation/translations-sync-action@v1
with:
download: npm run i18n:download
app-id: ${{ secrets.I18N_APP_ID }}
private-key: ${{ secrets.I18N_APP_PRIVATE_KEY }}
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.MICROBIT_ORG_CROWDIN_PERSONAL_ACCESS_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/translations-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: translations-upload

# Replaces the English catalogs in Crowdin. Run by hand from the Actions tab
# when the copy is stable enough to translate: sometimes that is a batch of
# features, sometimes a single string. Translations of strings whose English
# changed are cleared, as with a manual upload; tick "keep translations" for a
# correction translators need not revisit. `npm run i18n:upload -- --dry-run`
# locally shows the same diff.
on:
workflow_dispatch:
inputs:
keep_translations:
description: Keep translations of strings whose English text changed
type: boolean
default: false
dry_run:
description: Show what would change without uploading
type: boolean
default: false

concurrency:
group: translations-upload
cancel-in-progress: false

env:
# renovate: datasource=npm depName=npm
NPM_VERSION: "11"

jobs:
upload:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 24
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm install -g npm@${{ env.NPM_VERSION }} --registry=https://registry.npmjs.org
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm run i18n:upload -- ${{ inputs.keep_translations && '--keep-translations' || '' }} ${{ inputs.dry_run && '--dry-run' || '' }}
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.MICROBIT_ORG_CROWDIN_PERSONAL_ACCESS_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ yarn-error.log*
__pycache__
*.pyc
/reports/*
/crowdin/*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# Compiled message catalogs (run `npm run i18n:compile`)
/src/messages/*.json
53 changes: 0 additions & 53 deletions bin/compile-lang.mjs

This file was deleted.

84 changes: 0 additions & 84 deletions bin/crowdin-convert.cjs

This file was deleted.

64 changes: 0 additions & 64 deletions bin/tidy-lang.cjs

This file was deleted.

44 changes: 20 additions & 24 deletions bin/update-translations.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
#!/usr/bin/env bash
#
# Partial automation of updating translations.
# This process expects sibling checkouts of pyright and the stubs projects.
# Pulls every source of translated text into the editor. Expects sibling
# checkouts of our pyright fork (branch microbit) and the stubs repository
# (branch main), each on a clean branch ready for a pull request, and a
# CROWDIN_PERSONAL_TOKEN in the environment.
#
# Each repository has its own i18n.config.mjs for @microbit/i18n-tools; this
# script only strings the downloads and rebuilds together. The pyright fork
# does not install the tool, so npx fetches it there. New languages need
# adding to each config and the code changes listed in docs/tech-overview.md.
#
# New languages require code change in:
# 1. Pyright to add to the switch in localization.ts
# 2. Editor updates in settings.tsx and TranslationProvider.tsx.
#

set -euxo pipefail

if [ $# -eq 0 ]; then
echo Missing argument to extracted Crowdin ZIP >&1
exit 1
fi

languages="ca de es-ES fr ga-IE ja ko nl pl zh-CN zh-TW lol"

mkdir -p crowdin/translated
for language in $languages; do
lower="${language,,}"
prefix="${1}/${language}/new/apps/python-editor-v3"
cp "${prefix}/ui.en.json" "crowdin/translated/ui.${lower}.json"
cp "${prefix}/errors.en.json" "../pyright/packages/pyright-internal/src/localization/simplified.nls.${lower}.json"
cp "${prefix}/api.en.json" "../micropython-microbit-stubs/crowdin/translated/api.${lower}.json"
done
npm run i18n:convert
npm run i18n:compile
# UI strings.
npm run i18n:download

# API documentation, then rebuild the typeshed JSON from it.
(
cd ../micropython-microbit-stubs
npx microbit-i18n download
./scripts/build-translations.sh
)

# Error messages.
(
cd ../pyright
npx --yes --package @microbit/i18n-tools microbit-i18n download
)

./bin/update-pyright.sh
./bin/update-typeshed.sh
# We sometimes have newer English stubs than translations and don't want to
Expand Down
Loading