Skip to content

Commit 22a3c3d

Browse files
author
DocClaw
committed
Convert all preview_docs.sh output text to English
1 parent a6e2b12 commit 22a3c3d

1 file changed

Lines changed: 48 additions & 48 deletions

File tree

preview_docs.sh

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ RELEASE_DIR=""
5050
BRANCH_NAME=""
5151

5252
usage() {
53-
# Print the Usage section from the header comments (between Usage: and Notes: markers)
53+
# Print the Usage section from the header comments
5454
sed -n '/^# Usage:/,/^# Notes:/p' "$0" | head -n -1 | sed 's/^# //; s/^#$//'
5555
exit 1
5656
}
@@ -99,21 +99,21 @@ while [[ $# -gt 0 ]]; do
9999
usage
100100
;;
101101
*)
102-
echo "错误: 未知参数: $1"
102+
echo "Error: unknown argument: $1"
103103
usage
104104
;;
105105
esac
106106
done
107107

108108
# ---- Argument validation ----
109109
if [[ "$ACTION" != "single" && "$ACTION" != "multi" ]]; then
110-
echo "错误: 请指定 --pr ( PR) --multi (多 PR)"
110+
echo "Error: specify --pr (single PR) or --multi (multiple PRs)"
111111
usage
112112
fi
113113

114114
if [[ "$ACTION" == "single" ]]; then
115115
if [[ -z "$PR_TYPE" || -z "$PR_NUM" ]]; then
116-
echo "错误: --pr 需要指定类型和 PR 号,例如: --pr docs 12345"
116+
echo "Error: --pr requires a type and PR number, e.g. --pr docs 12345"
117117
usage
118118
fi
119119
case "$PR_TYPE" in
@@ -122,90 +122,90 @@ if [[ "$ACTION" == "single" ]]; then
122122
cloud) BRANCH_NAME="preview-cloud/pingcap/docs/$PR_NUM" ;;
123123
operator) BRANCH_NAME="preview-operator/pingcap/docs-tidb-operator/$PR_NUM" ;;
124124
*)
125-
echo "错误: 支持的 PR 类型: docs, docs-cn, cloud, operator"
125+
echo "Error: supported PR types: docs, docs-cn, cloud, operator"
126126
exit 1
127127
;;
128128
esac
129129
fi
130130

131131
if [[ "$ACTION" == "multi" ]]; then
132132
if [[ -z "$BRANCH_NAME" ]]; then
133-
echo "错误: 多 PR 模式需要 --branch-name 指定分支名"
133+
echo "Error: multi-PR mode requires --branch-name"
134134
usage
135135
fi
136136
if [[ -z "$DOCS_PR" && -z "$DOCS_CN_PR" && -z "$CLOUD_PR" && -z "$OPERATOR_PR" ]]; then
137-
echo "错误: 多 PR 模式至少需要指定一个 PR (--docs-pr, --docs-cn-pr, --cloud-pr, --operator-pr)"
137+
echo "Error: multi-PR mode requires at least one PR (--docs-pr, --docs-cn-pr, --cloud-pr, --operator-pr)"
138138
usage
139139
fi
140140
if [[ -z "$RELEASE_DIR" ]]; then
141-
echo "错误: 多 PR 模式需要 --release-dir 指定 release 目录 (例如 release-8.5)"
141+
echo "Error: multi-PR mode requires --release-dir (e.g. release-8.5)"
142142
usage
143143
fi
144144
fi
145145

146146
# ---- Print plan ----
147147
echo "═══════════════════════════════════════════"
148-
echo " 文档 PR 预览"
148+
echo " Doc PR Preview"
149149
echo "═══════════════════════════════════════════"
150150
if [[ "$ACTION" == "single" ]]; then
151-
echo " 模式: PR"
152-
echo " 类型: $PR_TYPE ($PR_NUM)"
151+
echo " Mode: Single PR"
152+
echo " Type: $PR_TYPE ($PR_NUM)"
153153
else
154-
echo " 模式: PR"
154+
echo " Mode: Multi PR"
155155
[[ -n "$DOCS_PR" ]] && echo " docs PR: $DOCS_PR"
156156
[[ -n "$DOCS_CN_PR" ]] && echo " docs-cn PR: $DOCS_CN_PR"
157157
[[ -n "$CLOUD_PR" ]] && echo " cloud PR: $CLOUD_PR"
158158
[[ -n "$OPERATOR_PR" ]] && echo " operator PR: $OPERATOR_PR"
159-
echo " release 目录: $RELEASE_DIR"
159+
echo " Release dir: $RELEASE_DIR"
160160
fi
161-
echo " 分支: $BRANCH_NAME"
162-
echo " 本地仓库: $REPO_DIR"
163-
echo " 干运行: $DRY_RUN"
161+
echo " Branch: $BRANCH_NAME"
162+
echo " Local repo: $REPO_DIR"
163+
echo " Dry run: $DRY_RUN"
164164
echo "═══════════════════════════════════════════"
165165

166166
# ---- Execution ----
167167

168-
# Step 1: Enter the repo directory
168+
# Step 1: cd into the repo
169169
cd "$REPO_DIR"
170170

171-
# Step 2: Ensure main is up-to-date
171+
# Step 2: Fetch latest main
172172
echo ""
173-
echo "⟳ 获取 main 最新代码..."
173+
echo "> Fetching latest main..."
174174
if [[ "$DRY_RUN" == true ]]; then
175-
echo " [干运行] git fetch $REMOTE main"
176-
echo " [干运行] git checkout main"
175+
echo " [dry-run] git fetch $REMOTE main"
176+
echo " [dry-run] git checkout main"
177177
else
178178
git fetch "$REMOTE" main
179179
git checkout main
180-
echo " ✓ main 已更新"
180+
echo " ✓ main updated"
181181
fi
182182

183-
# Step 3: Create a new branch from main
183+
# Step 3: Create new branch from main
184184
echo ""
185-
echo "⟳ 创建分支: $BRANCH_NAME..."
185+
echo "> Creating branch: $BRANCH_NAME..."
186186
if [[ "$DRY_RUN" == true ]]; then
187-
echo " [干运行] git checkout -b $BRANCH_NAME"
187+
echo " [dry-run] git checkout -b $BRANCH_NAME"
188188
else
189-
# Delete local branch if it already exists
189+
# Remove existing local branch with the same name
190190
if git branch --list "$BRANCH_NAME" | grep -q .; then
191191
git branch -D "$BRANCH_NAME"
192-
echo " ! 已删除本地已存在的同名分支"
192+
echo " ! Deleted existing local branch with same name"
193193
fi
194194
git checkout -b "$BRANCH_NAME"
195-
echo "分支已创建"
195+
echo "Branch created"
196196
fi
197197

198198
# Step 4: For multi-PR mode, modify sync_mult_prs.yml
199199
if [[ "$ACTION" == "multi" ]]; then
200200
echo ""
201-
echo "⟳ 修改 sync_mult_prs.yml 添加 PR 配置..."
201+
echo "> Updating sync_mult_prs.yml with PR config..."
202202

203203
WORKFLOW_FILE=".github/workflows/sync_mult_prs.yml"
204204

205205
if [[ "$DRY_RUN" == true ]]; then
206-
echo " [干运行] 在 $WORKFLOW_FILE 中添加:"
206+
echo " [dry-run] Modify $WORKFLOW_FILE:"
207207
echo " - push: branches: [$BRANCH_NAME]"
208-
echo " - env 变量:"
208+
echo " - env vars:"
209209
[[ -n "$DOCS_PR" ]] && echo " DOCS_PR: $DOCS_PR"
210210
[[ -n "$DOCS_CN_PR" ]] && echo " DOCS_CN_PR: $DOCS_CN_PR"
211211
[[ -n "$CLOUD_PR" ]] && echo " CLOUD_PR: $CLOUD_PR"
@@ -227,7 +227,7 @@ release_dir = "$RELEASE_DIR"
227227
with open(workflow_file, 'r') as f:
228228
content = f.read()
229229
230-
# Step 1: Insert push trigger after "on:" — add branch to push branches
230+
# Insert push trigger after "on:"
231231
old_on = "on:\n workflow_dispatch:"
232232
new_on = f"""on:
233233
push:
@@ -236,7 +236,7 @@ new_on = f"""on:
236236
workflow_dispatch:"""
237237
content = content.replace(old_on, new_on, 1)
238238
239-
# Step 2: Append PR env vars after the GITHUB_TOKEN line
239+
# Append PR env vars after the GITHUB_TOKEN line
240240
env_vars = []
241241
if docs_pr:
242242
env_vars.append(f" DOCS_PR: {docs_pr}")
@@ -255,49 +255,49 @@ for var in env_vars:
255255
with open(workflow_file, 'w') as f:
256256
f.write(content)
257257
258-
print(" ✓ sync_mult_prs.yml 已更新")
258+
print(" ✓ sync_mult_prs.yml updated")
259259
PYEOF
260260
fi
261261
fi
262262

263263
# Step 5: Commit and push
264264
echo ""
265-
echo "⟳ 提交并推送..."
265+
echo "> Committing and pushing..."
266266

267267
if [[ "$DRY_RUN" == true ]]; then
268-
echo " [干运行] git add . && git commit -m \"Preview: $BRANCH_NAME\""
269-
echo " [干运行] git push $REMOTE $BRANCH_NAME"
268+
echo " [dry-run] git add . && git commit -m \"Preview: $BRANCH_NAME\""
269+
echo " [dry-run] git push $REMOTE $BRANCH_NAME"
270270
else
271271
git add .
272272
if git diff --cached --quiet; then
273-
echo " ! 没有变更需要提交"
273+
echo " ! No changes to commit"
274274
else
275275
git commit -m "Preview: $BRANCH_NAME"
276-
echo "已提交"
276+
echo "Committed"
277277
fi
278278

279279
echo ""
280-
echo "⟳ 推送到远程..."
280+
echo "> Pushing to remote..."
281281
git push "$REMOTE" "$BRANCH_NAME"
282-
echo "已推送"
282+
echo "Pushed"
283283
fi
284284

285285
# Step 6: Print result summary
286286
echo ""
287287
echo "═══════════════════════════════════════════"
288-
echo "预览已就绪!"
288+
echo "Preview ready!"
289289
echo "═══════════════════════════════════════════"
290-
echo " 分支: $BRANCH_NAME"
291-
echo " 仓库: https://github.com/doc-claw-bot/pingcap-docsite-preview"
290+
echo " Branch: $BRANCH_NAME"
291+
echo " Repo: https://github.com/doc-claw-bot/pingcap-docsite-preview"
292292

293293
if [[ "$ACTION" == "multi" ]]; then
294294
echo ""
295-
echo " PR 配置已推送到分支 workflow 文件。"
296-
echo " 注意: 同步 PR 后,Cloudflare 会自动构建预览。"
297-
echo " 如需定期更新,请继续配置 sync_scheduler.yml"
295+
echo " Multi-PR config pushed on the branch workflow file."
296+
echo " Cloudflare will auto-build once the workflow syncs the PRs."
297+
echo " For periodic updates, configure sync_scheduler.yml."
298298
fi
299299

300300
echo ""
301-
echo " 查看运行状态:"
301+
echo " Check workflow status:"
302302
echo " https://github.com/doc-claw-bot/pingcap-docsite-preview/actions"
303303
echo "═══════════════════════════════════════════"

0 commit comments

Comments
 (0)