Files
Copilot 7c1498d278 Change Crowdin sync workflow to create PR instead of direct push (#202)
The Crowdin sync workflow currently pushes translation updates directly
to main. This bypasses review and can introduce issues unnoticed.

This change modifies this so that the action opens a PR instead.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kolaente <13721712+kolaente@users.noreply.github.com>
2025-12-21 08:59:03 +01:00

90 lines
3.2 KiB
YAML

name: Crowdin Sync
on:
schedule:
- cron: '0 0 * * *'
jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Crowdin sync
uses: crowdin/github-action@60debf382ee245b21794321190ad0501db89d8c1 # v2
with:
upload_sources: true
download_translations: true
push_translations: false
export_only_approved: true
skip_untranslated_strings: true
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Fix locale files for Flutter
run: |
cd lib/l10n
# Remove @@locale from all ARB files (Flutter infers from filename)
for file in *.arb; do
sed -i '/^[[:space:]]*"@@locale":/d' "$file"
done
# Remove redundant country-specific files where base locale exists
# Keep meaningful dialects: pt_BR, pt_PT, zh_CN, zh_TW
for file in app_*_*.arb; do
[ -f "$file" ] || continue
# Extract base and country (e.g., ar_SA -> ar, SA)
base=$(echo "$file" | sed -E 's/app_([a-z]+)_.*\.arb/\1/')
country=$(echo "$file" | sed -E 's/app_[a-z]+_(.*)\.arb/\1/')
basefile="app_${base}.arb"
# Skip meaningful dialect variants
case "${base}_${country}" in
pt_BR|pt_PT|zh_CN|zh_TW) continue ;;
esac
# If base file exists, remove redundant country-specific file
if [ -f "$basefile" ]; then
rm "$file"
else
# No base file - rename this to be the base
mv "$file" "$basefile"
fi
done
# Ensure base fallback files exist for dialect variants
for dialect in pt_BR pt_PT; do
if [ -f "app_${dialect}.arb" ] && [ ! -f "app_${dialect%_*}.arb" ]; then
echo '{}' > "app_${dialect%_*}.arb"
fi
done
for dialect in zh_CN zh_TW; do
if [ -f "app_${dialect}.arb" ] && [ ! -f "app_zh.arb" ]; then
echo '{}' > "app_zh.arb"
fi
done
- name: Create Pull Request
uses: crowdin/github-action@60debf382ee245b21794321190ad0501db89d8c1 # v2
with:
push_translations: true
create_pull_request: true
localization_branch_name: crowdin-sync
commit_message: 'chore(i18n): update translations via Crowdin'
pull_request_title: 'chore(i18n): update translations via Crowdin'
pull_request_body: |
This PR updates translations from Crowdin.
- Pushed source files to Crowdin
- Downloaded approved translations
- Fixed locale files for Flutter compatibility
Auto-generated by the Crowdin sync workflow.
github_user_name: 'Frederick [Bot]'
github_user_email: 'bot@vikunja.io'
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}