/
/
/
1name: Download Lokalise translations
2
3# Pulls the translated languages from the Lokalise server project back into the repo as
4# music_assistant/translations/<lang>.json (the flat layout the TranslationController reads at
5# runtime) and opens a PR. The English source is pushed to Lokalise by the companion
6# lokalise-upload.yml workflow, so the whole sync is driven by GitHub Actions (no reliance on
7# Lokalise's GitHub integration).
8#
9# Uses the org/repo secrets LOKALISE_RO_API_TOKEN (read-only token for download) and
10# LOKALISE_SERVER_PROJECT_ID (the Lokalise server project id). All languages present in the
11# Lokalise project are pulled; languages with no translations are skipped (--export-empty-as skip).
12
13on:
14 schedule:
15 - cron: "0 3 * * 2" # every Tuesday at 03:00 UTC
16 workflow_dispatch:
17
18# Pushes a branch and opens the translations PR, so it needs write + PR scope.
19permissions:
20 contents: write
21 pull-requests: write
22
23jobs:
24 download:
25 runs-on: ubuntu-latest
26 steps:
27 - uses: actions/checkout@v7
28 - name: Install Lokalise CLI
29 # pin the installer and CLI to a tagged release (don't run a script off a moving branch)
30 run: curl -sfL https://raw.githubusercontent.com/lokalise/lokalise-cli-2-go/v3.1.4/install.sh | sh -s -- -b ./bin v3.1.4
31 - name: Download translations
32 env:
33 VAR_LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_RO_API_TOKEN }}
34 VAR_LOKALISE_PROJECT_ID: ${{ secrets.LOKALISE_SERVER_PROJECT_ID }}
35 run: |
36 ./bin/lokalise2 \
37 --token "${VAR_LOKALISE_API_TOKEN}" \
38 --project-id "${VAR_LOKALISE_PROJECT_ID}" \
39 file download \
40 --format json \
41 --export-empty-as skip \
42 --export-sort first_added \
43 --placeholder-format raw \
44 --original-filenames=false \
45 --bundle-structure "music_assistant/translations/%LANG_ISO%.json" \
46 --indentation 2sp \
47 --replace-breaks=false \
48 --async
49 - name: Create Pull Request
50 env:
51 GH_TOKEN: ${{ github.token }}
52 GITHUB_NEW_BRANCH_NAME: Lokalise-${{ github.run_id }}${{ github.run_attempt }}
53 run: |
54 git checkout -b "${GITHUB_NEW_BRANCH_NAME}"
55 git config --global user.name "${GITHUB_ACTOR}"
56 git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
57 git add music_assistant/translations/\*.json
58 git reset -- music_assistant/translations/en.json
59 if [[ -z $(git status --untracked-files=no --porcelain) ]]; then
60 echo "No translation changes"
61 else
62 git commit -m 'Translations update'
63 git push --set-upstream origin "${GITHUB_NEW_BRANCH_NAME}"
64 gh pr create --base dev --head "${GITHUB_NEW_BRANCH_NAME}" --title "Lokalise translations update" --body ""
65 fi
66