Files
2026-08-15 21:14:27 +08:00

68 lines
2.3 KiB
YAML

name: L10n
on:
workflow_dispatch:
concurrency:
group: codegen
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
jobs:
l10n:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
run_install: |
- cwd: web
package_json_file: web/package.json
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Setup Go
uses: actions/setup-go@v7
with:
cache: true
go-version: 'stable'
- name: Install gettext
run: |
sudo apt-get install -y gettext
- name: Install xgotext
run: |
go install github.com/leonelquinteros/gotext/cli/xgotext@latest
- name: Generate pot files and commit
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
~/go/bin/xgotext -default backend -pkg-tree ./cmd/ace -out ./pkg/embed/locales
(cd web && pnpm run gettext:extract)
# extract 会连带重写译文 po,但它们由 Crowdin 托管且折行格式不同,还原以免格式差异淹没真实翻译
find web/src/locales -name '*.po' ! -name 'en.po' -exec git checkout -- {} +
if [ -z "$(git status --porcelain)" ]; then
echo "pot 文件无变更,跳过提交"
exit 0
fi
git add -A
git commit -m "chore(l10n): update pot files"
git push origin HEAD:main
- name: Sync with Crowdin
uses: crowdin/github-action@v2
with:
config: crowdin.yml
upload_sources: true
upload_translations: false
download_translations: true
export_only_approved: true
create_pull_request: true
pull_request_title: 'l10n: sync translations with Crowdin'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}