Skip to content

Commit fc1280f

Browse files
Merge branch 'dev' of https://github.com/1bananachicken/MaaNTE into dev
2 parents 8a2e7f0 + 0d4c977 commit fc1280f

22 files changed

Lines changed: 2021 additions & 116 deletions

.github/workflows/i18n-sync.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: i18n-sync
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
reviewer:
7+
description: "自动请求评审的 GitHub 用户名(可留空)"
8+
required: false
9+
schedule:
10+
# 每天 UTC 03:00 自动运行(可按需调整) 测试
11+
- cron: "0 3 * * *"
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
env:
18+
I18N_SYNC_BRANCH: "chore/i18n-auto-sync"
19+
PR_TITLE: "chore: auto sync OCR i18n expected"
20+
DEFAULT_PR_REVIEWER: "EeeMaoY"
21+
22+
jobs:
23+
sync-ocr-expected:
24+
if: github.event_name == 'workflow_dispatch' || github.repository == '1bananachicken/MaaNTE'
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ secrets.MAANTE_BOT_TOKEN }}
31+
fetch-depth: 0
32+
33+
- name: Setup Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.12"
37+
38+
- name: Prepare fixed sync branch
39+
env:
40+
BASE_BRANCH: ${{ github.event.repository.default_branch }}
41+
run: |
42+
git checkout -B "$I18N_SYNC_BRANCH" "origin/$BASE_BRANCH"
43+
44+
- name: Clone translation repository
45+
run: |
46+
git clone --depth 1 https://github.com/Abino01/ExtractForNTE.git "$RUNNER_TEMP/ExtractForNTE"
47+
48+
- name: Show translation repository commit
49+
run: |
50+
git -C "$RUNNER_TEMP/ExtractForNTE" rev-parse HEAD
51+
52+
- name: Run OCR expected sync (write mode)
53+
run: |
54+
python tools/i18n/sync_ocr_expected.py --write --i18n-dir "$RUNNER_TEMP/ExtractForNTE"
55+
56+
- name: Check changes
57+
id: changes
58+
run: |
59+
if git diff --quiet; then
60+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
61+
else
62+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
63+
fi
64+
65+
- name: Commit and push changes
66+
if: steps.changes.outputs.has_changes == 'true'
67+
uses: actions-js/push@master
68+
with:
69+
force: true
70+
branch: ${{ env.I18N_SYNC_BRANCH }}
71+
message: "chore: auto sync OCR i18n expected [skip changelog]"
72+
github_token: ${{ secrets.MAANTE_BOT_TOKEN }}
73+
74+
- name: Create PR when missing
75+
if: steps.changes.outputs.has_changes == 'true'
76+
env:
77+
GH_TOKEN: ${{ secrets.MAANTE_BOT_TOKEN }}
78+
BASE_BRANCH: ${{ github.event.repository.default_branch }}
79+
PR_REVIEWER: ${{ github.event.inputs.reviewer || env.DEFAULT_PR_REVIEWER }}
80+
run: |
81+
pr_number="$(gh pr list --base "$BASE_BRANCH" --head "$I18N_SYNC_BRANCH" --state open --json number --jq '.[0].number')"
82+
if [ -n "$pr_number" ]; then
83+
echo "PR already exists: #$pr_number"
84+
if [ -n "$PR_REVIEWER" ]; then
85+
if ! output="$(gh pr edit "$pr_number" --add-reviewer "$PR_REVIEWER" 2>&1)"; then
86+
if echo "$output" | grep -qi "already requested"; then
87+
echo "Skip add reviewer (already requested)"
88+
else
89+
echo "$output" >&2
90+
exit 1
91+
fi
92+
fi
93+
fi
94+
exit 0
95+
fi
96+
pr_body="$(cat <<'EOF'
97+
## Summary
98+
- Auto run i18n OCR expected sync.
99+
- Update expected values based on latest ExtractForNTE translation repository.
100+
101+
## Trigger
102+
- workflow_dispatch
103+
- schedule (daily UTC)
104+
EOF
105+
)"
106+
reviewer_args=()
107+
if [ -n "$PR_REVIEWER" ]; then
108+
reviewer_args=(--reviewer "$PR_REVIEWER")
109+
fi
110+
gh pr create \
111+
--base "$BASE_BRANCH" \
112+
--head "$I18N_SYNC_BRANCH" \
113+
--title "$PR_TITLE" \
114+
--body "$pr_body" \
115+
"${reviewer_args[@]}"
116+
117+
- name: Show changed files
118+
run: |
119+
git status --short

assets/resource/base/pipeline/ClaimRewards.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@
5252
404
5353
],
5454
"expected": [
55-
"领取"
55+
"领取",
56+
"領取",
57+
"(?i)Claim",
58+
"受け取る",
59+
"수령"
5660
],
5761
"threshold": 0.8
5862
}
@@ -112,7 +116,11 @@
112116
52
113117
],
114118
"expected": [
115-
"全部领取"
119+
"全部领取",
120+
"全部領取",
121+
"(?i)Claim\\s*All",
122+
"一括受取",
123+
"모두 수령"
116124
],
117125
"threshold": 0.8
118126
}
@@ -154,7 +162,11 @@
154162
49
155163
],
156164
"expected": [
157-
"全部领取"
165+
"全部领取",
166+
"全部領取",
167+
"(?i)Claim\\s*All",
168+
"一括受取",
169+
"모두 수령"
158170
],
159171
"threshold": 0.8
160172
}

assets/resource/base/pipeline/Fish/Fish.json

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@
132132
40
133133
],
134134
"expected": [
135-
"万能鱼饵"
135+
"万能鱼饵",
136+
"萬能魚餌",
137+
"(?i)Universal\\s*Bait",
138+
"万能釣り餌",
139+
"만능 미끼"
136140
],
137141
"action": "ClickKey",
138142
"key": [
@@ -152,7 +156,18 @@
152156
44
153157
],
154158
"expected": [
155-
"更换"
159+
"更换",
160+
"更換",
161+
"(?i)Switch",
162+
"入れ替え",
163+
"替换",
164+
"替換",
165+
"(?i)Swap",
166+
"変更",
167+
"切换",
168+
"切換",
169+
"切り替え",
170+
"교체"
156171
],
157172
"threshold": 0.8
158173
}
@@ -174,7 +189,11 @@
174189
44
175190
],
176191
"expected": [
177-
"购买"
192+
"购买",
193+
"購買",
194+
"(?i)Purchase",
195+
"購入",
196+
"구매"
178197
],
179198
"threshold": 0.8
180199
}
@@ -206,7 +225,11 @@
206225
44
207226
],
208227
"expected": [
209-
"购买"
228+
"购买",
229+
"購買",
230+
"(?i)Purchase",
231+
"購入",
232+
"구매"
210233
],
211234
"threshold": 0.8
212235
}

0 commit comments

Comments
 (0)