Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

translation features.md to Chinese#1192

Merged
tiangolo merged 6 commits intofastapi:masterfrom
Dustyposa:translation_zh
May 16, 2020
Merged

translation features.md to Chinese#1192
tiangolo merged 6 commits intofastapi:masterfrom
Dustyposa:translation_zh

Conversation

@Dustyposa
Copy link
Contributor

We have a small team doing that translation en docs to Chinese.
If you are interested on this thing. Can join us,and speed the translate.:smile:

tiangolo and Weiney reacted with heart emojitiangolo reacted with rocket emoji
@codecov
Copy link

codecovbot commentedMar 31, 2020
edited
Loading

Codecov Report

Merging#1192 intomaster willnot change coverage.
The diff coverage isn/a.

Impacted file tree graph

@@            Coverage Diff            @@##            master     #1192   +/-   ##=========================================  Coverage   100.00%   100.00%           =========================================  Files          226       226             Lines         6785      6785           =========================================  Hits          6785      6785

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update4e77737...1465369. Read thecomment docs.

### 基于开放标准


* 用于创建API的 <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> 包含了<abbr title="也被叫做: endpoints, routes">路径</abbr><abbr title="也叫做HTTP方法, 例如POST, GET, PUT, DELETE">操作</abbr>,请求参数,请求体,安全性等说明。
Copy link
Contributor

Choose a reason for hiding this comment

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

"declarations" should be "声明".


* 用于创建API的 <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> 包含了<abbr title="也被叫做: endpoints, routes">路径</abbr><abbr title="也叫做HTTP方法, 例如POST, GET, PUT, DELETE">操作</abbr>,请求参数,请求体,安全性等说明。
* 使用 <a href="http://json-schema.org/" class="external-link" target="_blank"><strong>JSON Schema</strong></a> ( OpenAPI 本身就是基于 JSON Schema 的)自动生成数据模型文档。
* 经过了缜密的研究,围绕这些标准被设计出来的。而不是想到什么就在顶层加上什么。
Copy link
Contributor

Choose a reason for hiding this comment

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

"经过缜密研究后围绕这些标准而设计。并非狗尾续貂。" should be better?

* 用于创建API的 <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> 包含了<abbr title="也被叫做: endpoints, routes">路径</abbr><abbr title="也叫做HTTP方法, 例如POST, GET, PUT, DELETE">操作</abbr>,请求参数,请求体,安全性等说明。
* 使用 <a href="http://json-schema.org/" class="external-link" target="_blank"><strong>JSON Schema</strong></a> ( OpenAPI 本身就是基于 JSON Schema 的)自动生成数据模型文档。
* 经过了缜密的研究,围绕这些标准被设计出来的。而不是想到什么就在顶层加上什么。
* 这也允许在很多语言中使用自动**客户端代码生成**。
Copy link
Contributor

Choose a reason for hiding this comment

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

"这也允许在很多语言中自动生成客户端代码" reads better.

* 这也允许在很多语言中使用自动**客户端代码生成**。
### 自动生成文档

交互式 API 文档以及具探索性 web 界面。因为该框架是基于 OpenAPI ,所以有很多可选选项,默认情况下只设置了两个。
Copy link
Contributor

Choose a reason for hiding this comment

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

"web 界面" and "OpenAPI ," have extra spaces.


全部都基于标准的 **Python 3.6 类型**声明(感谢 Pydantic )。没有新的语法需要学习。只需要标准的 Python 。

如果你需要2分钟来学习如何使用 Python 类型(即使你不使用 FastAPI ),看看这个简短的教程:[Python Types](python-types.md){.internal-link target=_blank}。
Copy link
Contributor

Choose a reason for hiding this comment

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

”学习“ should be "复习" or "回顾”


### 编辑器支持

所有的框架都被设计得易于使用且直观,所有的决定都在开发之前就在多个编辑器上进行了测试,来确保最佳的开发体验。
Copy link
Contributor

Choose a reason for hiding this comment

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

"所有的框架" should be "整个框架"


整个 **FastAPI** 框架就是基于这一点的。任何地方都可以进行自动补全。

你就不需要经常再来看这个文档。
Copy link
Contributor

Choose a reason for hiding this comment

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

“你不会需要经常回来看文档” reads better.


![editor support](https://fastapi.tiangolo.com/img/pycharm-completion.png)

你将在代码中完成你在之前可能曾认为不可能的事。例如,在来自请求 JSON 体(可能是嵌套的)中的键`price`。
Copy link
Contributor

Choose a reason for hiding this comment

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

"completion in code" should be "代码补全" not "在代码中完成"




### 总结
Copy link
Contributor

Choose a reason for hiding this comment

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

"Short" should be “简洁" or "简短"?


任何类型都有合理的**默认值**,任何和地方都有可选配置。所有的参数被微调,来满足你的需求,定义成你需要的API。

但是默认情况下,所有都是**“能够工作”**。
Copy link
Contributor

Choose a reason for hiding this comment

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

"在默认情况下,一切都能顺利工作" reads better?

* UUID。
* ...及其他。

所有的验证都由完善且强大的 **Pydantic** 处理。
Copy link
Contributor

Choose a reason for hiding this comment

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

“验证” -> “校验"


### 安全性及身份验证

集成了安全性和身份认证。不影响数据库或者数据模型。
Copy link
Contributor

Choose a reason for hiding this comment

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

"Without any compromise" means like "杜绝渗透风险”.

* 查询参数。
* Cookies, 等等。

加上来自Starlette(包括 **session cookie**)的所有安全特性。
Copy link
Contributor

Choose a reason for hiding this comment

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

missing a space before "Starlette"


FastAPI 有一个使用非常简单,但是非常强大的<abbr title='也叫做 "components", "resources", "services", "providers"'><strong>依赖注入</strong></abbr>系统。

* 甚至依赖关系也可以有依赖关系,创建一个层级或者**“图”依赖关系**。
Copy link
Contributor

Choose a reason for hiding this comment

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

"依赖关系“ is incorrect.


* 甚至依赖也可以有依赖,创建一个层级或者**“图”依赖**。
* 所有**自动化处理**都由框架完成。
* 所有的依赖关系都可以从请求中获取数据,并且**增加了路径操作**约束和自动文档生成。
Copy link
Contributor

Choose a reason for hiding this comment

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

所有注入的依赖都可以从请求中获取数据、扩充路径操作的约束条件并自动生成文档

* 甚至依赖也可以有依赖,创建一个层级或者**“图”依赖**。
* 所有**自动化处理**都由框架完成。
* 所有的依赖关系都可以从请求中获取数据,并且**增加了路径操作**约束和自动文档生成。
* 即使在依赖项中被定义的*路径操作* 也会**自动验证**。
Copy link
Contributor

Choose a reason for hiding this comment

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

missing “parameters”,“即使在依赖项中被定义的路径操作参数也会被自动验证。”


### 无限制"插件"

或者说,导入并使用你需要的代码,而不需要它们。
Copy link
Contributor

Choose a reason for hiding this comment

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

或者换句话说,不需要上面这么复杂,就只是导入并使用你需要的代码。


或者说,导入并使用你需要的代码,而不需要它们。

任何集成都被设计得被易于使用(用依赖关系),你可以用和*路径操作*相同的结构和语法,在两行代码中为你的应用创建一个“插件”。
Copy link
Contributor

Choose a reason for hiding this comment

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

通过注入依赖,任何的集成都被设计得非常易于使用,你可以用和路径操作相同的结构和语法,只用两行代码为你的应用创建一个“插件”。


* 100% <abbr title="自动测试的代码量">测试覆盖</abbr>。
* 代码库100% <abbr title="Python类型注解,有了这个你的编辑器和外部工具可以给你更好的支持">类型注释</abbr>。
* 用于生产应用。
Copy link
Contributor

Choose a reason for hiding this comment

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

这里强调的应该是“Used”,就是已经在生产环境中被使用,被验证过可靠性了。已在线上应用中使用


兼容包括基于 Pydantic 的外部库, 例如用与数据库的 <abbr title="对象关系映射">ORM</abbr>s, <abbr title="对象文档映射">ODM</abbr>s。

这也意味着在很多情况下,你可以将从请求中获得的相同对象**直接传到数据库**,因为所有的验证都是自动的。
Copy link
Contributor

Choose a reason for hiding this comment

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

“因为所有的验证都是自动的。”should be “因为一切都会被自动验证”


反之亦然,在很多情况下,你也可以将从数据库中获取的对象**直接传到客户端**。

通过 **FastAPI** 你可以获得所有 **Pydantic** (FastAPI 基于 Pydantic 做了所有的数据处理):
Copy link
Contributor

Choose a reason for hiding this comment

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

missing “features”

通过FastAPI 你可以获得所有Pydantic 的特性 (因为 FastAPI 整个的数据处理部分都是基于 Pydantic 的):


* **更简单**:
* 没有新的模式定义 micro-language 需要学习。
* 如果你知道 Python types,你就知道如何使用 Pydantic。
Copy link
Contributor

Choose a reason for hiding this comment

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

如果你了解 Python 的类型

通过 **FastAPI** 你可以获得所有 **Pydantic** (FastAPI 基于 Pydantic 做了所有的数据处理):

* **更简单**:
* 没有新的模式定义 micro-language 需要学习。
Copy link
Contributor

Choose a reason for hiding this comment

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

不需要学习一套新的规则或语言用来定义模式

* 验证器允许复杂的数据架构能被清晰简单地定义,检查并记录为 JSON Schema。
* 你可以拥有深度**嵌套的 JSON** 对象并对它们进行验证和注释。
* **可扩展**:
* Pydantic 允许定义自定义数据类型或者你可以用验证器装饰器对被装饰的模型上的方法扩展验证。
Copy link
Contributor

Choose a reason for hiding this comment

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

Pydantic 允许自定义数据类型,或者你可以用验证器装饰器装饰数据模型的方法来扩展验证功能。

### 基于开放标准


* 用于创建API的 <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> 包含了<abbr title="也被叫做: endpoints, routes">路径</abbr><abbr title="也叫做HTTP方法, 例如POST, GET, PUT, DELETE">操作</abbr>,请求参数,请求体,安全性等的声明。
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave space before and afterAPI:
"用于创建API的" should be "用于创建 API 的"



* 用于创建API的 <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> 包含了<abbr title="也被叫做: endpoints, routes">路径</abbr><abbr title="也叫做HTTP方法, 例如POST, GET, PUT, DELETE">操作</abbr>,请求参数,请求体,安全性等的声明。
* 使用 <a href="http://json-schema.org/" class="external-link" target="_blank"><strong>JSON Schema</strong></a> ( OpenAPI 本身就是基于 JSON Schema 的)自动生成数据模型文档。
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 应该使用中文符号(括号)。
  2. as 应该翻译出来:因为
* 使用 <a href="http://json-schema.org/"><strong>JSON Schema</strong></a> 自动生成数据模型文档(因为OpenAPI 本身就是基于 JSON Schema 的)。

* 使用 <a href="http://json-schema.org/" class="external-link" target="_blank"><strong>JSON Schema</strong></a> ( OpenAPI 本身就是基于 JSON Schema 的)自动生成数据模型文档。
* 经过了缜密的研究后围绕这些标准而设计。并非狗尾续貂。
* 这也允许了在很多语言中自动**生成客户端代码**。
### 自动生成文档
Copy link
Contributor

Choose a reason for hiding this comment

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

Better leave a blank line before this line.

* 这也允许了在很多语言中自动**生成客户端代码**。
### 自动生成文档

交互式 API 文档以及具探索性 web 界面。因为该框架是基于 OpenAPI,所以有很多可选选项,默认情况下只设置了两个。
Copy link
Contributor

Choose a reason for hiding this comment

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

It's hard to understand "默认情况下只设置了两个". 补全主语宾语会更容易理解。

因为该框架是基于 OpenAPI,所以有很多可选项,FastAPI 默认自带两个交互式 API 文档。


整个框架都被设计得易于使用且直观,所有的决定都在开发之前就在多个编辑器上进行了测试,来确保最佳的开发体验。

在最近的 Python 开发者调查中,我们能看到<a href="https://www.jetbrains.com/research/python-developers-survey-2017/#tools-and-features" class="external-link" target="_blank">被使用最多的功能是"自动补全"</a>。
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave a space before and after<a href="https://www.jetbrains.com/research/python-developers-survey-2017/#tools-and-features">


![editor support](https://fastapi.tiangolo.com/img/pycharm-completion.png)

你将能进行代码补全,这是在之前你可能曾认为不可能的事。例如,在来自请求 JSON 体(可能是嵌套的)中的键`price`。
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave a space beforeprice.


你将能进行代码补全,这是在之前你可能曾认为不可能的事。例如,在来自请求 JSON 体(可能是嵌套的)中的键`price`。

不会再输错键名,来回翻看文档,或者来回滚动寻找你最后使用的`username`或者`user_name`。
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave spaces before and after English words.


### 简洁

任何类型都有合理的**默认值**,任何和地方都有可选配置。所有的参数被微调,来满足你的需求,定义成你需要的API。
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave spaces before and after English words.

* **支持 GraphQL** 。
* 后台任务处理。
* Startup 和 shutdown 事件。
* 测试客户端基于`requests`。
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave spaces before and afterrequests.

* 在 <a href="https://pydantic-docs.helpmanual.io/#benchmarks-tag" class="external-link" target="_blank">基准测试</a> 中,Pydantic 比其他被测试的库都要快。
* 验证**复杂结构**:
* 使用分层的 Pydantic 模型, Python `typing`的 `List` 和 `Dict` 等等。
* 验证器允许复杂的数据架构能被清晰简单地定义,检查并记录为 JSON Schema。
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 物作主语时allow 应该翻译成使得 , 参考 Collins 词典。
  2. defined, checked, documented 三者为并列关系。

V-T If one thing allows another thing to happen, the first thing creates the opportunity for the second thing to happen.

验证器使我们能够简单清楚的将复杂的数据模式定义、检查并记录为 JSON Schema。

@Dustyposa
Copy link
ContributorAuthor

Thanks for your review.
@waynerv@RunningIkkyu
😄
🚀

RunningIkkyu and Weiney reacted with laugh emojiWeiney reacted with rocket emoji

@tiangolotiangolo merged commita0cdbe4 intofastapi:masterMay 16, 2020
@tiangolo
Copy link
Member

Awesome! Thanks for your contribution@Dustyposa ! ☕ 🙇 👏

And thanks for the reviews@waynerv and@RunningIkkyu ! 🙇 🍰

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

Reviewers

2 more reviewers

@RunningIkkyuRunningIkkyuRunningIkkyu approved these changes

@waynervwaynervwaynerv approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Dustyposa@tiangolo@RunningIkkyu@waynerv

[8]ページ先頭

©2009-2026 Movatter.jp