📝 Improve translation prompt to avoid AI-style writing in chinese docs by lennney · Pull Request #15711 · fastapi/fastapi · GitHub
Skip to content

📝 Improve translation prompt to avoid AI-style writing in chinese docs#15711

Open
lennney wants to merge 8 commits into
fastapi:masterfrom
lennney:fix/zh-translation-prompt
Open

📝 Improve translation prompt to avoid AI-style writing in chinese docs#15711
lennney wants to merge 8 commits into
fastapi:masterfrom
lennney:fix/zh-translation-prompt

Conversation

@lennney

@lennney lennney commented Jun 9, 2026

Copy link
Copy Markdown

What

Improve docs/zh/llm-prompt.md — the prompt that drives LLM-generated Chinese translations — to eliminate common AI-style writing patterns.

Problem

The current Chinese translations are grammatically correct but read like AI output: overly formal, verbose, with English-influenced sentence structure. Examples from the live docs:

Current translation Natural Chinese
"最简单的 FastAPI 文件可能像下面这样" "长这样"
"将其复制到 main.py 文件中" "复制到 main.py 里"
"该行显示了你的应用在本机所提供服务的 URL 地址" "这行告诉你应用跑在哪个地址"
"它并非具体的实现代码,而只是抽象的描述" "不是具体代码,就是个抽象描述"

The root cause: the translation prompt has glossary and formatting rules, but zero guidance on writing style.

Changes

Added a "Writing style" section to docs/zh/llm-prompt.md:

  1. 5 core rules — one sentence one idea, short sentences, spoken Chinese word order, keep English technical terms, no hedging
  2. 12 anti-patterns with real examples — each taken from actual FastAPI zh translations, with the fix and the reason
  3. 8 more patterns to watch for — "你可以在...中找到", "值得注意的是", "在这种情况下", etc.
  4. 3 reference style guides — Vue.js zh docs, 阮一峰, Go by Example zh
  5. Expanded glossary — from 4 to 22 terms (dependency injection, middleware, validation, endpoint, decorator, etc.)

Also refined "Grammar and tone" to explicitly state "用'你'不用'您'" and add guidance on dropping unnecessary subjects.

Total: 1 file changed, +73/-4 lines.

Why this approach

FastAPI's contributing guide says the best way to improve zh translations is to improve the LLM prompt — this changes the source, not the symptoms.

Add a 'Writing style' section to the Chinese LLM translation prompt
that addresses common AI-generated translation patterns:

- Core rules: one sentence one idea, short sentences, spoken word order
- 12 concrete anti-patterns with real examples from current zh docs
- Reference style guides (Vue.js zh docs, 阮一峰, Go by Example zh)
- Expanded glossary from 4 to 22 terms (dependency injection, middleware,
  validation, endpoint, decorator, etc.)

The current zh translations are grammatically correct but read like
AI output — overly formal, verbose, with English-influenced sentence
structure. This prompt improvement targets the root cause: the LLM
that generates the translations lacks style guidance.
Copilot AI review requested due to automatic review settings June 9, 2026 00:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the Chinese (zh) LLM translation prompt to produce more natural, developer-oriented Simplified Chinese by adding detailed style guidance and expanding the glossary.

Changes:

  • Added a “Writing style” section with concrete rules and anti-pattern examples for more natural Chinese.
  • Refined grammar/tone guidance (use “你”, avoid over-explaining, often drop explicit subjects).
  • Expanded the preferred translations / glossary with more common technical terms.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/zh/llm-prompt.md Outdated
| 将其复制到...文件中 | 复制到...里 | "将其" is literary, not spoken |
| 该行显示了...的URL地址 | 这行告诉你...的地址 | "该" as a pronoun is stiff; "地址" already implies URL |
| 你将会看到 | 你会看到 | "将会" is news-anchor tone |
| 它并非...而只是... | 不是...就是... | "并非...而只是" is essay-style |
Comment thread docs/zh/llm-prompt.md Outdated
Comment on lines +21 to +25
| ❌ Don't write | ✅ Write instead | Why |
|---|---|---|
| 将其复制到...文件中 | 复制到...里 | "将其" is literary, not spoken |
| 该行显示了...的URL地址 | 这行告诉你...的地址 | "该" as a pronoun is stiff; "地址" already implies URL |
| 你将会看到 | 你会看到 | "将会" is news-anchor tone |

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25f140371c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/zh/llm-prompt.md Outdated
| 将其复制到...文件中 | 复制到...里 | "将其" is literary, not spoken |
| 该行显示了...的URL地址 | 这行告诉你...的地址 | "该" as a pronoun is stiff; "地址" already implies URL |
| 你将会看到 | 你会看到 | "将会" is news-anchor tone |
| 它并非...而只是... | 不是...就是... | "并非...而只是" is essay-style |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve negation in the replacement pattern

When the source means “not X, but only Y” (the exact case represented by 它并非...而只是...), the suggested replacement 不是...就是... changes the meaning to an either/or construction in Chinese. Because this prompt is used to generate future zh translations, that pattern can make the LLM drop the original negation and produce semantically incorrect docs instead of just less formal wording.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📝 Docs preview

Last commit 9df073a at: https://fcbf70b2.fastapitiangolo.pages.dev

'不是...就是...' means 'either...or...' (disjunction), not the
intended contrast. Changed to '不是...只是...' which preserves
the original 'not X, but merely Y' meaning while still being
more natural than '并非...而只是...'.

Addresses Copilot and Codex review feedback.
@YuriiMotov

Copy link
Copy Markdown
Member

I re-translated several pages using this updated prompt.

@lennney, please, review the results: diff or previews

If you confirm that translations became better, we will ask other native speakers to review this PR

@YuriiMotov YuriiMotov added lang-all Translations lang-zh Chinese translations waiting labels Jun 9, 2026
@alejsdev alejsdev changed the title docs(zh): improve translation prompt to avoid AI-style writing 📝 Improve translation prompt to avoid AI-style writing in chinese docs Jun 9, 2026
@lennney

lennney commented Jun 9, 2026

Copy link
Copy Markdown
Author

lennney added 5 commits June 10, 2026 09:32
- Add terminology tiers (must-translate / keep-English / prose-only)
- Add admonition type preservation rule (info ≠ note)
- Add HTML attribute rules (alt text in Chinese)
- Add W3C Chinese spacing rules
- Add consistency rules (request body vs body)
- Add core rules: preserve meaning, avoid slang
- Expand anti-pattern table with new examples
- Add new terms to glossary (body, form, file, etc.)

Based on Vue.js translation guide, Microsoft style, and LLM prompt
engineering best practices.
…i-patterns

Round 2 improvements based on PR fastapi#15717 analysis (18 violations found):

- Fix Tier 1/Tier 2 contradiction: decorator, endpoint moved to Tier 3
- Add core rule 9: 其他 not 其它
- Add core rule 10: no repeated conjunctions 并...并
- Add anchor ID rule (never translate {#...})
- Add code block rule (no translation inside code/comments)
- Add more anti-patterns: 另一个→另一套, 模型对象的→模型的
- Add redundant 你的 examples with specific fixes
- Extend Tier 2 with tools (VS Code, PyCharm, Celery, etc.)
- Clarify Body class vs body concept distinction
- Add cross-document consistency rule
- Add rule 11: Tier 3 terms in prose must be translated even if Python keywords
- Add rule 12: omit 会 for deterministic behavior
- Add terminology teaching section (first occurrence English + annotation)
- Add pre-translation scan rule (check existing files for consistency)

3 rounds of iteration: 18 → 17 → 0 new rule gaps identified.
Align with Chinese Python community convention where type annotations
are called 类型注解, not 类型标注.
- Add terminology glossary (71+ terms) with NOT alternatives
- Add anti-patterns table (16 rules for natural Chinese)
- Add good translation examples (7 side-by-side comparisons)
- Add post-translation review checklist
- Add spacing rules for Chinese-English formatting
- Categories: FastAPI core (23), Web (14), Python (24), Dev tools (10)
- Keep-English list: frameworks, protocols, abbreviations, class names
- Based on analysis of existing translations and PR fastapi#15717
@YuriiMotov

This comment was marked as resolved.

- Remove 'Post-translation review' (not applicable to chat completions)
- Remove 'Code blocks' section (already in general prompt)
- Remove 'HTML attributes' section (general prompt has abbr/dfn rules)
- Remove 'Anchor IDs' from Headings (already in general prompt)
- Add notes that Headings and Admonitions supplement the general prompt

Addresses feedback from @YuriiMotov on PR fastapi#15711.
@lennney

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review lang-all Translations lang-zh Chinese translations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants