Skip to content

🌐 Update Chinese translation for docs/tutorial/security/simple-oauth2.md - #3844

Merged
tiangolo merged 5 commits into
fastapi:masterfrom
jaystone776:Update-Chinese-Translation-for-docs-tutorial-security-simple-oauth2.md
Sep 25, 2023
Merged

tiangolo merged 5 commits into
fastapi:masterfrom
jaystone776:Update-Chinese-Translation-for-docs-tutorial-security-simple-oauth2.md

Conversation

@jaystone776

Copy link
Copy Markdown
Contributor

as title

@codecov

codecov Bot commented Sep 1, 2021 •

Copy link
Copy Markdown

Codecov Report

Patch and project coverage have no change.

Comparison is base (cf73051) 100.00% compared to head (a4467b1) 100.00%.

❗ Current head a4467b1 differs from pull request most recent head 62212be. Consider uploading reports for the commit 62212be to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #3844     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          540       410    -130     
  Lines        13969     10281   -3688     
===========================================
- Hits         13969     10281   -3688     

see 179 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions

github-actions Bot commented Sep 1, 2021

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit a4467b1 at: https://612f2537f71da87cecc1f9f3--fastapi.netlify.app

@tiangolo tiangolo changed the title Update Chinese Translation for docs\tutorial\security\simple-oauth2.md 🌐 Update Chinese translation for docs/tutorial/security/simple-oauth2.md Oct 5, 2021
@tiangolo tiangolo added awaiting-review lang-all Translations lang-zh Chinese translations labels Oct 5, 2021
@github-actions github-actions Bot mentioned this pull request Oct 5, 2021
@github-actions

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit d99b77f at: https://638367c3cb23926ae9f8ad08--fastapi.netlify.app

@github-actions

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit a864982 at: https://639ce8e42c118d097747f852--fastapi.netlify.app

@tiangolo

Copy link
Copy Markdown
Member

📝 Docs preview for commit 62212be at: https://649a1ad41636a413a2534ba0--fastapi.netlify.app

@xzmeng xzmeng 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.

LGTM.
This PR attempts to polish the sentences to make the chapter more easier to read, and there is no change in meaning.

并且,这两个字段必须命名为 `username` 和 `password` ,不能使用 `user-name` 或 `email` 等其它名称。

不过不用担心,你可以在前端按照你的想法将它展示给最终用户。
不过也不用担心,前端仍可以显示终端用户所需的名称。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The English text here is:

https://github.com/tiangolo/fastapi/blob/f7e3559bd5997f831fb9b02bef9c767a50facbc3/docs/en/docs/tutorial/security/simple-oauth2.md?plain=1#L13

I guess the original translation is better because here "终端用户所需" introduces a misleading idea that the name displayed is required/specified by the end user (instead of the developer, as the original English text suggests).

数据库模型也可以使用所需的名称。

但是对于登录*路径操作*,我们需要使用这些名称来与规范兼容(以具备例如使用集成的 API 文档系统的能力)。
但对于登录*路径操作*,则要使用兼容规范的 `username` 和 `password`,(例如,实现与 API 文档集成)。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here is a redundant comma. Also, the orginal English says:

https://github.com/tiangolo/fastapi/blob/f7e3559bd5997f831fb9b02bef9c767a50facbc3/docs/en/docs/tutorial/security/simple-oauth2.md?plain=1#L17

So I think the "例如" here is unclear. We need to point out that the example is used to explain the advantage of complying with the specs.

Suggested change
但对于登录*路径操作*,则要使用兼容规范的 `username` 和 `password`,(例如,实现与 API 文档集成)。
但对于登录*路径操作*,则要使用兼容规范的 `username` 和 `password`(以具备诸如使用集成的 API 文档系统这样的能力)。

但对于登录*路径操作*,则要使用兼容规范的 `username` 和 `password`,(例如,实现与 API 文档集成)。

规范还写明了 `username` 和 `password` 必须作为表单数据发送(因此,此处不能使用 JSON)。
该规范要求必须以表单数据形式发送 `username` 和 `password`,因此,不能使用 JSON 对象。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

https://github.com/tiangolo/fastapi/blob/f7e3559bd5997f831fb9b02bef9c767a50facbc3/docs/en/docs/tutorial/security/simple-oauth2.md?plain=1#L19

The translation of also is missed and I think some degree of respect for the original text is still needed, so the annotation marks like parenthesis should be reserved.

Suggested change
该规范要求必须以表单数据形式发送 `username` 和 `password`,因此,不能使用 JSON 对象。
该规范还要求必须以表单数据形式发送 `username` 和 `password`(因此不能使用 JSON 对象)。

该规范要求必须以表单数据形式发送 `username` 和 `password`,因此,不能使用 JSON 对象。

### `scope`
### `Scope`(作用域)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be better to keep the same lowercase in a code block, just like the original text.

Suggested change
### `Scope`(作用域)
### `scope`(作用域)

OAuth2 还支持客户端发送**`scope`**表单字段。

这个表单字段的名称为 `scope`(单数形式),但实际上它是一个由空格分隔的「作用域」组成的长字符串。
虽然表单字段的名称是 `scope`(单数),但实际上,它是以空格分隔的,由多个**scope**组成的长字符串。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
虽然表单字段的名称是 `scope`(单数),但实际上,它是以空格分隔的,由多个**scope**组成的长字符串。
虽然表单字段的名称是 `scope`(单数),但实际上,它是由多个「作用域」组成的长字符串,各个作用域之间使用空格分割。

* Facebook / Instagram 使用 `instagram_basic`。
* Google 使用了 `https://www.googleapis.com/auth/drive` 。
* 常见用例为,`users:read` 或 `users:write`
* 脸书和 Instagram 使用 `instagram_basic`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
* 脸书和 Instagram 使用 `instagram_basic`
* Facebook 和 Instagram 使用 `instagram_basic`

Just be consistent. It would be so weird if one product name is translated and the other is not.

Personally speaking, it would be better to leave the names of the products as-is when the products

  • don't provide service in China mainland.
  • don't have an official translation of the product name in Chinese.
  • are technically mentioned for development usage (In this case, readers will be more familiar with the English terms).

* Google 使用了 `https://www.googleapis.com/auth/drive` 。
* 常见用例为,`users:read` 或 `users:write`
* 脸书和 Instagram 使用 `instagram_basic`
* 谷歌使用 `https://www.googleapis.com/auth/drive`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
* 谷歌使用 `https://www.googleapis.com/auth/drive`
* Google 使用 `https://www.googleapis.com/auth/drive`

!!! info
在 OAuth2 中「作用域」只是一个声明所需特定权限的字符串。
!!! info "说明"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change

Keep the line number consistent with the original text so that the git diff tool will not align the change incorrectly.

!!! info "说明"

它有没有 `:` 这样的其他字符或者是不是 URL 都没有关系。
OAuth2 中,**作用域**只是声明指定权限的字符串。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
OAuth2 中,**作用域**只是声明指定权限的字符串。
OAuth2 中,「作用域」只是声明某种权限的字符串。

## 获取 `username` 和 `password` 的代码

现在,让我们使用 **FastAPI** 提供的实用工具来处理此问题。
接下来,使用 **FastAPI** 工具获取用户名与密码。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't see a reason why to leave out some words here. The wording seems to mean that FastAPI is a tool designed to get the username and password.

Suggested change
接下来,使用 **FastAPI** 工具获取用户名与密码。
接下来,使用 **FastAPI** 提供的实用工具来获取用户名与密码。

@tiangolo

Copy link
Copy Markdown
Member

Thanks @jaystone776! 🚀

And thanks for the reviews @Sefank, @xzmeng, @mkdir700! 🙇

I'll merge this one for now, but if there are changes needed on top we can handle them in additional PRs. 🤓

@tiangolo
tiangolo merged commit 0e2ca1c into fastapi:master Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-2 lang-all Translations lang-zh Chinese translations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants