Skip to content

Offline gym log for Android. No account, no ads, no internet.

Match @@locale to the file names in Crowdin pull requests

InlitXb94c2692c541
diff --git a/.github/workflows/crowdin-locale.yml b/.github/workflows/crowdin-locale.yml
new file mode 100644
index 0000000..9551c59
--- /dev/null
+++ b/.github/workflows/crowdin-locale.yml
@@ -0,0 +1,34 @@
+name: Fix Crowdin locales
+
+on:
+ pull_request_target:
+ branches: [main]
+ types: [opened, synchronize, reopened]
+
+permissions:
+ contents: write
+
+# Crowdin writes its own language codes into @@locale (es-ES, pt-PT, zh-CN…),
+# and gen-l10n refuses to build when @@locale doesn't match the file name.
+jobs:
+ fix:
+ if: github.head_ref == 'l10n_main' && github.event.pull_request.head.repo.full_name == github.repository
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ ref: l10n_main
+
+ - name: Match @@locale to the file name
+ run: |
+ for f in lib/l10n/app_*.arb; do
+ code=$(basename "$f" .arb)
+ code=${code#app_}
+ sed -i -E "s/(\"@@locale\": *\")[^\"]*\"/\1$code\"/" "$f"
+ done
+ if git diff --quiet; then exit 0; fi
+ git config user.name "github-actions[bot]"
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ git commit -am "Match @@locale to the file names"
+ git push origin HEAD:l10n_main