Skip to content

Commit 59e6f47

Browse files
authored
[DOC] Fix wrong CN translate (vllm-project#11652)
Fix wrong CN translate - vLLM version: v0.23.0 - vLLM main: vllm-project/vllm@1f486d9 Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
1 parent c48ca3f commit 59e6f47

67 files changed

Lines changed: 15071 additions & 16853 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/scripts/detect_po_changes.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,38 @@ def _po_entry_block(msgid: str) -> str:
280280
return "\n".join(parts)
281281

282282

283+
def _dedup_po_entries(po: POFile) -> int:
284+
"""Remove duplicate entries from *po*, keeping only the first.
285+
286+
Covers two cases:
287+
- Duplicate msgid values (same paragraph extracted multiple times).
288+
- Duplicate empty msgid (``msgid ""``) — only the first (which carries
289+
the PO header metadata like ``Project-Id-Version``) is kept; any
290+
additional bare ``msgid ""`` entries are removed. Without this,
291+
``polib`` may shuffle the bare entry's position relative to the
292+
header block on every save, causing spurious diffs.
293+
294+
Returns the number of entries removed.
295+
"""
296+
seen: set[str] = set()
297+
removed = 0
298+
empty_seen = False
299+
for entry in list(po):
300+
if not entry.msgid:
301+
if empty_seen:
302+
po.remove(entry)
303+
removed += 1
304+
else:
305+
empty_seen = True
306+
continue
307+
if entry.msgid in seen:
308+
po.remove(entry)
309+
removed += 1
310+
else:
311+
seen.add(entry.msgid)
312+
return removed
313+
314+
283315
def process_file(source_path: Path, dry_run: bool = False, force: bool = False) -> bool:
284316
"""Create or update the .po file for *source_path*.
285317
@@ -310,6 +342,14 @@ def process_file(source_path: Path, dry_run: bool = False, force: bool = False)
310342

311343
# Incremental update: detect new, removed, and modified paragraphs.
312344
po = pofile(str(po_path))
345+
346+
# Deduplicate existing entries — keep only the first occurrence of each
347+
# msgid; mark duplicates as obsolete. Without this step, repeated
348+
# invocations on files that already contain duplicate msgid entries
349+
# (e.g. from prior force rebuilds or buggy incremental runs) would
350+
# keep appending more copies.
351+
_dedup_po_entries(po)
352+
313353
entries_by_msgid: dict[str, POEntry] = {}
314354
for entry in po:
315355
if entry.msgid:
@@ -319,8 +359,25 @@ def process_file(source_path: Path, dry_run: bool = False, force: bool = False)
319359
modified_count = 0
320360
removed_count = 0
321361

362+
# Track how many times each paragraph appears in the source so that
363+
# repeated paragraphs (e.g. "Offline example:") consume one PO entry
364+
# each without creating spurious "new" entries.
365+
para_counts: dict[str, int] = {}
366+
for para in paragraphs:
367+
para_counts[para] = para_counts.get(para, 0) + 1
368+
322369
for para in paragraphs:
323-
if para in entries_by_msgid:
370+
remaining = para_counts.get(para, 0)
371+
if para in entries_by_msgid and remaining > 0:
372+
del entries_by_msgid[para]
373+
para_counts[para] = remaining - 1
374+
continue
375+
# If the source has more occurrences of *para* than the PO has
376+
# entries, we need to create additional entries.
377+
if remaining > 0:
378+
para_counts[para] = remaining - 1
379+
po.append(_build_po_entry(para))
380+
new_count += 1
324381
continue
325382
# Check if this is a modification of an existing paragraph
326383
# (similar msgid that got updated in the source).
@@ -357,6 +414,13 @@ def process_file(source_path: Path, dry_run: bool = False, force: bool = False)
357414
return True
358415

359416
po.save(str(po_path))
417+
# Work around polib 1.2.0 unstable header serialization (the bare
418+
# ``msgid ""``/``msgstr ""`` block drifts relative to the metadata
419+
# header block on consecutive saves). Loading and saving a second
420+
# time stabilizes the output — polib's own round-trip is then
421+
# deterministic.
422+
po2 = pofile(str(po_path))
423+
po2.save(str(po_path))
360424
parts = []
361425
if new_count:
362426
parts.append(f"+{new_count} new")

.github/workflows/scripts/po_translate.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,16 @@
5757
5858
--- WHAT TO PRESERVE (keep EXACTLY as in msgid) ---
5959
4. All format specifiers: %s, %d, %f, {{}}, {{{{}}}}, {{name}}, etc.
60-
5. All markdown syntax: **bold**, *italic*, `inline code`, ```code blocks```,
61-
[links](urls), ![images](urls), # headings, - lists, 1. ordered lists,
62-
> blockquotes, | tables, --- horizontal rules.
60+
5. All markdown syntax MUST be preserved exactly:
61+
- Headings: "#", "##", "###", etc. at the start of a line
62+
- Bold/italic: **bold**, *italic*
63+
- Inline code: `code`
64+
- Code blocks: ```code blocks```
65+
- Links: [text](url), ![images](url)
66+
- List markers: "- ", "* ", "1. ", "2. " at the start of each list item
67+
- Blockquotes: "> "
68+
- Tables: | columns |, separator rows (|:---:|)
69+
- Horizontal rules: ---
6370
6. HTML tags and attributes: <div>, <a href>, <img>, etc.
6471
7. Environment variables, file paths, command names, code identifiers.
6572
8. Proper nouns: person names, contributor names, author names, company names,
@@ -103,7 +110,10 @@
103110
18. For markdown links [text](url): translate the display text in [] but keep
104111
the URL in () exactly as-is.
105112
Example: [Quick Start](quick_start.md) → [快速开始](quick_start.md)
106-
19. For headings (# Title): translate the heading text.
113+
19. For headings: translate the heading text but KEEP the "#" / "##" / "###"
114+
prefix exactly as in the msgid.
115+
Example: msgid "# Quick Start" → msgstr "# 快速开始"
116+
Example: msgid "## Overview" → msgstr "## 概述"
107117
20. DO NOT add "#, fuzzy" markers.
108118
21. If a msgid is purely structural (symbols, code, file paths only), copy it
109119
verbatim to msgstr.

docs/source/locale/zh_CN/LC_MESSAGES/community/slash-commands.po

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ msgid ""
3939
"automatically routed to the appropriate NPU runner based on the test path."
4040
msgstr "运行 `tests/e2e/pull_request/` 下的特定 E2E 测试。测试会根据路径自动路由到相应的 NPU 运行器。"
4141

42-
msgid "**Examples:**"
43-
msgstr "**示例:**"
44-
4542
msgid "**Routing rules** (matched in order):"
4643
msgstr "**路由规则**(按顺序匹配):"
4744

@@ -88,9 +85,6 @@ msgstr ""
8885
"`schedule_nightly_test_a2.yaml` 和 `schedule_nightly_test_a3.yaml` 中定义的 "
8986
"`test_config.name` 条目。"
9087

91-
msgid "**Usage:**"
92-
msgstr "**用法:**"
93-
9488
msgid ""
9589
"| Syntax | Scope |\n"
9690
"|---|---|\n"
@@ -152,9 +146,6 @@ msgstr ""
152146
"`deepseek-r1-0528-w8a8`, `kimi-k2-thinking`, "
153147
"`qwen3-vl-235b-a22b-instruct-w8a8`, `custom-multi-ops`, ..."
154148

155-
msgid "**Examples:**"
156-
msgstr "**示例:**"
157-
158149
msgid ""
159150
"This triggers `workflow_dispatch` on both `schedule_nightly_test_a2.yaml` "
160151
"and `schedule_nightly_test_a3.yaml`."
@@ -170,9 +161,6 @@ msgid ""
170161
"PR. This is useful for backporting fixes to release branches."
171162
msgstr "将一个 PR 的提交 cherry-pick 到指定的目标分支并创建一个新的 PR。这对于将修复反向移植到发布分支非常有用。"
172163

173-
msgid "**Usage:**"
174-
msgstr "**用法:**"
175-
176164
msgid ""
177165
"| Syntax | Description |\n"
178166
"|---|---|\n"
@@ -182,9 +170,6 @@ msgstr ""
182170
"|---|---|\n"
183171
"| `/cherry-pick <target_branch>` | Cherry-pick 到指定分支 |"
184172

185-
msgid "**Examples:**"
186-
msgstr "**示例:**"
187-
188173
msgid ""
189174
"A new PR will be created with the title format `[Cherry-pick] "
190175
"<original_title> (from #<PR_NUMBER>)` and a body linking back to the "
@@ -304,3 +289,18 @@ msgid ""
304289
msgstr ""
305290
"权限通过 GitHub API (`repos/{owner}/{repo}/collaborators/{user}/permission`) "
306291
"进行验证。"
292+
293+
msgid "**Examples:**"
294+
msgstr ""
295+
296+
msgid "**Usage:**"
297+
msgstr ""
298+
299+
msgid "**Examples:**"
300+
msgstr ""
301+
302+
msgid "**Usage:**"
303+
msgstr ""
304+
305+
msgid "**Examples:**"
306+
msgstr ""

docs/source/locale/zh_CN/LC_MESSAGES/developer_guide/Design_Documents/ModelRunner_prepare_inputs.po

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ msgstr "这些假设条件在启动vLLM时配置。它们并非固定不变,
170170
msgid "### Step 1: All requests in the prefill phase"
171171
msgstr "### 步骤1:所有请求处于预填充阶段"
172172

173-
msgid "#### Obtain inputs"
174-
msgstr "#### 获取输入"
175-
176173
msgid ""
177174
"As the maximum number of tokens that can be scheduled is 10, the scheduled "
178175
"tokens of each request can be represented as `{'0': 3, '1': 2, '2': 5}`. "
@@ -272,9 +269,6 @@ msgstr ""
272269
"- `Input IDs` = `[T_0_0, T_0_1, T_0_2, T_1_0, T_1_1, T_2_0, T_2_1, T_3_2, "
273270
"T_3_3, T_3_4]`"
274271

275-
msgid "#### Build inputs attention metadata"
276-
msgstr "#### 构建输入注意力元数据"
277-
278272
msgid ""
279273
"In the current **Block Table**, we use the first block (i.e. block_0) to "
280274
"mark the unused block. The shape of the block is `(max num request, max "
@@ -471,3 +465,9 @@ msgid ""
471465
"model forwarding. If you have any good ideas, you are welcome to contribute "
472466
"to us."
473467
msgstr "希望本文档能帮助你更好地理解 vLLM 如何为模型前向传播准备输入。如果你有任何好的想法,欢迎向我们贡献。"
468+
469+
msgid "#### Obtain inputs"
470+
msgstr ""
471+
472+
msgid "#### Build inputs attention metadata"
473+
msgstr ""

0 commit comments

Comments
 (0)