Skip to content

Commit 0025b94

Browse files
committed
feat:(workflow) add sync-target-files.yml
1 parent 90c8804 commit 0025b94

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 🧰 (P) ] Update i18n source files"
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
sync-files:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout f18n repository
13+
uses: actions/checkout@v4
14+
with:
15+
path: f18n-central
16+
17+
- name: Checkout Floorp repository
18+
uses: actions/checkout@v4
19+
with:
20+
repository: Floorp-Projects/Floorp-12
21+
path: floorp
22+
23+
- name: Read translation targets
24+
id: read-targets
25+
run: |
26+
TARGETS=$(cat floorp/src/apps/i18n-supports/translation-targets.json)
27+
echo "targets<<EOF" >> $GITHUB_OUTPUT
28+
echo "$TARGETS" >> $GITHUB_OUTPUT
29+
echo "EOF" >> $GITHUB_OUTPUT
30+
31+
- name: Generate Crowdin.yml
32+
run: |
33+
cd f18n-central
34+
TARGETS='${{ steps.read-targets.outputs.targets }}'
35+
echo "files:" > crowdin.yml
36+
echo "$TARGETS" | jq -c '.targets[]' | while read -r target; do
37+
SOURCE_PATH=$(echo "$target" | jq -r '.source_path')
38+
SOURCE_FILE=$(echo "$TARGETS" | jq -r '.source_file')
39+
echo " - source: /$SOURCE_PATH/$SOURCE_FILE" >> crowdin.yml
40+
echo " translation: /$SOURCE_PATH/%locale%.json" >> crowdin.yml
41+
echo "" >> crowdin.yml
42+
done
43+
44+
- name: Copy translation files
45+
run: |
46+
cd f18n-central
47+
TARGETS='${{ steps.read-targets.outputs.targets }}'
48+
echo "$TARGETS" | jq -c '.targets[]' | while read -r target; do
49+
SOURCE_PATH=$(echo "$target" | jq -r '.source_path')
50+
F18N_PATH=$(echo "$target" | jq -r '.f18n_path')
51+
SOURCE_FILE=$(echo "$TARGETS" | jq -r '.source_file')
52+
echo "Copying $SOURCE_FILE from $SOURCE_PATH to $F18N_PATH"
53+
mkdir -p "$F18N_PATH"
54+
cp "../floorp/$SOURCE_PATH/$SOURCE_FILE" "$F18N_PATH"
55+
done
56+
57+
- name: Commit and push changes
58+
run: |
59+
cd f18n-central
60+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
61+
git config --global user.name "github-actions[bot]"
62+
git add .
63+
git commit -m "[Bot] Update i18n source files from main repository"
64+
git push

0 commit comments

Comments
 (0)