Skip to content

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

Keep Crowdin pull requests in the repo's layout and leave Spanish out

InlitX157ed3049387
diff --git a/.github/workflows/crowdin-locale.yml b/.github/workflows/crowdin-locale.yml
index 9551c59..2139725 100644
--- a/.github/workflows/crowdin-locale.yml
+++ b/.github/workflows/crowdin-locale.yml
@@ -1,4 +1,4 @@
-name: Fix Crowdin locales
+name: Tidy Crowdin translations
on:
pull_request_target:
@@ -20,15 +20,14 @@ jobs:
with:
ref: l10n_main
- - name: Match @@locale to the file name
+ - name: Match @@locale and the repo layout
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 fetch --depth=1 origin main
+ git checkout origin/main -- lib/l10n/app_es.arb
+ git show origin/main:tool/arb_tidy.py > "$RUNNER_TEMP/arb_tidy.py"
+ python3 "$RUNNER_TEMP/arb_tidy.py"
+ if git diff --quiet HEAD; 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 commit -am "Tidy the translation files"
git push origin HEAD:l10n_main
diff --git a/crowdin.yml b/crowdin.yml
index 0df1fe1..fc93cc8 100644
--- a/crowdin.yml
+++ b/crowdin.yml
@@ -1,6 +1,8 @@
files:
- source: /lib/l10n/app_en.arb
translation: /lib/l10n/app_%two_letters_code%.arb
+ excluded_target_languages:
+ - es-ES
languages_mapping:
two_letters_code:
zh-TW: zh_Hant
diff --git a/tool/arb_tidy.py b/tool/arb_tidy.py
new file mode 100644
index 0000000..633234b
--- /dev/null
+++ b/tool/arb_tidy.py
@@ -0,0 +1,18 @@
+import glob
+import json
+import os
+
+ROOT = os.path.join('lib', 'l10n')
+order = [k for k in json.load(open(os.path.join(ROOT, 'app_en.arb'), encoding='utf-8')) if not k.startswith('@')]
+
+for path in sorted(glob.glob(os.path.join(ROOT, 'app_*.arb'))):
+ code = os.path.basename(path)[4:-4]
+ if code == 'en':
+ continue
+ data = json.load(open(path, encoding='utf-8'))
+ keys = [k for k in order if k in data] + [k for k in data if not k.startswith('@') and k not in order]
+ lines = [f' "@@locale": "{code}"'] + [f' {json.dumps(k)}: {json.dumps(data[k], ensure_ascii=False)}' for k in keys]
+ text = '{\n' + ',\n'.join(lines) + '\n}\n'
+ json.loads(text)
+ with open(path, 'w', encoding='utf-8', newline='\n') as f:
+ f.write(text)