You've already forked coreutils-l10n
mirror of
https://github.com/uutils/coreutils-l10n.git
synced 2026-06-10 16:14:28 -07:00
108 lines
3.0 KiB
YAML
108 lines
3.0 KiB
YAML
name: Weblate Synchronization
|
|
|
|
on:
|
|
# Run every 6 hours to sync with Weblate
|
|
schedule:
|
|
- cron: '0 */6 * * *'
|
|
|
|
# Allow manual triggering
|
|
workflow_dispatch:
|
|
|
|
# Trigger on push to main branch (for source updates)
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'src/uu/*/locales/en-US.ftl'
|
|
- 'src/uucore/locales/en-US.ftl'
|
|
- 'src/uu/*/src/*.rs'
|
|
|
|
jobs:
|
|
sync-weblate:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
token: ${{ secrets.WEBLATE_TOKEN || github.token }}
|
|
fetch-depth: 0
|
|
|
|
- name: Install Weblate CLI
|
|
run: |
|
|
pip install wlc
|
|
|
|
- name: Configure Weblate CLI
|
|
run: |
|
|
mkdir -p ~/.config
|
|
cat > ~/.config/weblate << EOF
|
|
[weblate]
|
|
url = https://hosted.weblate.org/api/
|
|
|
|
[keys]
|
|
https://hosted.weblate.org/api/ = ${{ secrets.WEBLATE_API_KEY }}
|
|
EOF
|
|
|
|
- name: Install Mozilla Fluent Linter
|
|
run: |
|
|
pip install moz-fluent-linter
|
|
|
|
- name: Pull translations from Weblate
|
|
run: |
|
|
wlc pull rust-coreutils
|
|
|
|
- name: Fix Fluent syntax issues
|
|
run: |
|
|
# Ensure all .ftl files end with a newline
|
|
find src/uu/*/locales src/uucore/locales -name "*.ftl" -type f | while read -r f; do
|
|
if [ -s "$f" ] && [ "$(tail -c1 "$f" | wc -l)" -eq 0 ]; then
|
|
echo "" >> "$f"
|
|
echo "Fixed missing newline: $f"
|
|
fi
|
|
done
|
|
|
|
# Fix ## group comments to # single comments (Fluent syntax)
|
|
find src/uu/*/locales src/uucore/locales -name "*.ftl" -type f | while read -r f; do
|
|
if grep -qP '^## ' "$f"; then
|
|
sed -i 's/^## /# /' "$f"
|
|
echo "Fixed ## comments: $f"
|
|
fi
|
|
done
|
|
|
|
- name: Validate Fluent syntax
|
|
run: |
|
|
has_errors=false
|
|
for dir in $(find src/uu/*/locales src/uucore/locales -name "*.ftl" -type f -exec dirname {} \; | sort -u); do
|
|
if ! moz-fluent-lint --config .github/fluent_linter_config.yml "$dir"; then
|
|
echo "::warning::Fluent syntax issues in $dir"
|
|
has_errors=true
|
|
fi
|
|
done
|
|
if [ "$has_errors" = true ]; then
|
|
echo "::warning::Some Fluent files have syntax issues that could not be auto-fixed"
|
|
fi
|
|
|
|
- name: Commit and push translations
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
git add src/uu/*/locales/*.ftl src/uucore/locales/*.ftl
|
|
git commit -m "Update translations from Weblate"
|
|
git push
|
|
else
|
|
echo "No translation updates to commit"
|
|
fi
|
|
|
|
- name: Push source changes to Weblate
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
# Lock translations to prevent conflicts
|
|
wlc lock rust-coreutils
|
|
|
|
# Push source changes
|
|
wlc push rust-coreutils
|
|
|
|
# Unlock after push
|
|
wlc unlock rust-coreutils
|