Check zh translation prompt by YuriiMotov · Pull Request #15717 · fastapi/fastapi · GitHub
Skip to content

Check zh translation prompt#15717

Closed
YuriiMotov wants to merge 3 commits into
masterfrom
check-zh-translation-prompt
Closed

Check zh translation prompt#15717
YuriiMotov wants to merge 3 commits into
masterfrom
check-zh-translation-prompt

Conversation

@YuriiMotov

Copy link
Copy Markdown
Member

This is a temporary PR just to check how LLM translates to Chinese with changes to LLM prompt from PR #15711.

To generate it I deleted the existing translations of those files (with existing translations LLM preserved existing wording and didn't update much).

Please, check if the changes to the prompt improve the translation

lennney and others added 3 commits June 9, 2026 00:48
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.
'不是...就是...' 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 YuriiMotov added lang-all Translations lang-zh Chinese translations labels Jun 9, 2026
Comment thread docs/zh/llm-prompt.md
- function: 函数
- class: 类
- type: 类型
- annotation: 标注

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

annotation: 注解

lennney added a commit to lennney/fastapi that referenced this pull request Jun 10, 2026
…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
FastAPI 不靠 `str | None` 来判断是否必填。它看默认值 `= None`。

但添加这些类型注解可以让你的编辑器提供更好的支持并检测错误
但加上类型标注,编辑器能提供更好的支持并发现错误

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

类型标注 -> 类型注解

@YuriiMotov

Copy link
Copy Markdown
Member Author

@lennney, do you need more time before others review the PR?
Keep in mind, that your latest updates made re-generated pages outdated.. Now I have to re-generate them again and native speakers will have to review them again.
This is why I previously asked you to confirm if it's ready for review or not

可以同时声明路径参数和请求体。

**FastAPI** 能识别与**路径参数**匹配的函数参数应该**从路径中获取**,而声明为 Pydantic 模型的函数参数应该**从请求体中获取**
FastAPI 会识别:和路径参数同名的函数参数来自路径。声明为 Pydantic 模型的函数参数来自请求体

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FastAPI 会识别:和路径参数同名的函数参数来自路径,声明为 Pydantic 模型的函数参数来自请求体。

@lennney

lennney commented Jun 10, 2026

Copy link
Copy Markdown

@YuriiMotov Thanks for the heads up! The prompt is now ready for review.

I did 3 rounds of iteration based on your PR #15717 translations — analyzed each file against the prompt rules, found gaps, and refined the prompt. Here is what changed:

New rules added:

  • Terminology tiers (3 layers: must-translate / keep-English / prose vs code)
  • Admonition type preservation (infonote)
  • HTML alt text must stay in Chinese (accessibility)
  • W3C Chinese spacing rules
  • Cross-document consistency (not just within one file)
  • Core rules 9-12: 其他 not 其它, no repeated conjunctions, Tier 3 terms in prose, omit 会 for deterministic behavior
  • Pre-translation scan (check existing files before translating)
  • Terminology teaching section (first occurrence English + annotation)

Anti-pattern table expanded from 12 to 20 entries.

The prompt went from 115 lines to 221 lines. You can regenerate the translations with the updated prompt — it should fix most of the issues found in the first round (small老弟, 依赖和基座, alt text, body vs 请求体, etc.).

Let me know when you have regenerated and I will review again!

@YuriiMotov YuriiMotov closed this Jun 10, 2026
@lennney

lennney commented Jun 10, 2026

Copy link
Copy Markdown

Sorry for the back-and-forth — I should have had the prompt finalized before you re-generated the pages the first time. That is on me.

The prompt is stable now. No more changes planned unless you find issues with the regenerated output.

@YuriiMotov

Copy link
Copy Markdown
Member Author

@lennney, I decided to skip re-generation for now (it's quite time-consuming).
Let's wait for PR #15711 reviews, apply suggestions (if any), and then I will re-translate several pages to check it before merging PR #15711.

@lennney

lennney commented Jun 10, 2026

Copy link
Copy Markdown

@YuriiMotov Got it, that makes sense.

Meanwhile, I will regenerate the translations on my end to do a self-review first. WaketZheng also left some helpful suggestions (e.g. "annotation" → "注解" instead of "标注"), so I will incorporate those into the prompt before anything else.

Sorry again for the extra rounds. I will make sure everything is solid this time.

@lennney

lennney commented Jun 10, 2026

Copy link
Copy Markdown

lennney added a commit to lennney/fastapi that referenced this pull request Jun 10, 2026
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang-all Translations lang-zh Chinese translations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants