This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-website.git
The following commit(s) were added to refs/heads/master by this push:
new 5113d0538 feat: sync translations from Caslingo
5113d0538 is described below
commit 5113d053819d57792f75fa705dda1b3f7aaadea8
Author: Yang Luo <[email protected]>
AuthorDate: Tue Nov 3 18:33:06 2026 +0800
feat: sync translations from Caslingo
---
.github/workflows/master.yml | 6 +++---
package.json | 2 +-
scripts/caslingo-sync.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml
index 13967f99a..99ce0021b 100644
--- a/.github/workflows/master.yml
+++ b/.github/workflows/master.yml
@@ -30,7 +30,7 @@ jobs:
permissions:
contents: write
env:
- CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
+ CASLINGO_TOKEN: ${{ secrets.CASLINGO_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -44,9 +44,9 @@ jobs:
- name: Install dependencies
run: yarn install
- - name: Crowdin sync
+ - name: Caslingo sync
if: github.event_name != 'pull_request'
- run: yarn crowdin:sync
+ run: yarn caslingo:sync
- name: Generate footer stars
run: yarn generate:footer-stars
diff --git a/package.json b/package.json
index 3e2fe0d59..4aec779a6 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
"lint": "yarn lint:js && yarn lint:css && yarn lint:md",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
- "crowdin:sync": "docusaurus write-translations && crowdin upload &&
crowdin download",
+ "caslingo:sync": "bash scripts/caslingo-sync.sh",
"prepare": "husky install"
},
"dependencies": {
diff --git a/scripts/caslingo-sync.sh b/scripts/caslingo-sync.sh
new file mode 100644
index 000000000..5d92d354e
--- /dev/null
+++ b/scripts/caslingo-sync.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# Takes the translations from Caslingo
(https://caslingo.casdoor.com/projects/casbin-website) before the build:
+# uploads the site texts that `docusaurus write-translations` generates, asks
Caslingo to pull this commit and waits
+# for it, then downloads the translation files of every language into i18n/.
+set -euo pipefail
+
+url="${CASLINGO_URL:-https://caslingo.casdoor.com}"
+project=casbin-website
+auth="Authorization: Bearer ${CASLINGO_TOKEN:?set CASLINGO_TOKEN to the access
token of the Caslingo project}"
+commit="${GITHUB_SHA:-$(git rev-parse HEAD)}"
+
+yarn docusaurus write-translations --locale en
+for f in $(find i18n/en -name '*.json' | sort); do
+ curl -fsS -H "$auth" -H "Content-Type: application/octet-stream"
--data-binary @"$f" \
+ "$url/api/upload-source?project=$project&path=$f&sync=false" > /dev/null
+done
+
+# if Caslingo is busy pulling an earlier commit, it pulls again when that is
done
+curl -fsS -X POST -H "$auth" "$url/api/start-job?project=$project&kind=sync" >
/dev/null
+synced=""
+for _ in $(seq 1 60); do
+ synced=$(curl -fsS -H "$auth" "$url/api/get-project?project=$project" | node
-e 'let
s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s).data.lastSyncCommit||""))')
+ [ "$synced" = "$commit" ] && break
+ sleep 10
+done
+if [ "$synced" != "$commit" ]; then
+ echo "Caslingo has not pulled $commit after 10 minutes (it has $synced);
using its translations as they are"
+fi
+
+curl -fsS -H "$auth" "$url/api/download-translations?project=$project" -o
translations.zip
+unzip -o -q translations.zip
+rm translations.zip
+
+# translated pages import what sits next to them (a styles.module.css), as the
English pages do
+for locale in $(ls i18n); do
+ [ "$locale" = en ] && continue
+ for pair in docs:docusaurus-plugin-content-docs/current
blog:docusaurus-plugin-content-blog; do
+ src=${pair%%:*}
+ dst=i18n/$locale/${pair#*:}
+ find "$src" -type f ! -name '*.md' ! -name '*.mdx' | while read -r f; do
+ mkdir -p "$dst/$(dirname "${f#$src/}")"
+ cp "$f" "$dst/${f#$src/}"
+ done
+ done
+done
+echo "translations of $(ls -d i18n/*/ | grep -v '/en/$' | wc -l) languages
from Caslingo"
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]