Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌐 Add Chinese translation for docs/zh/docs/tutorial/background-tasks.md #9812

Merged
merged 4 commits into from
Jul 27, 2023

Conversation

wdh99
Copy link
Contributor

@wdh99 wdh99 commented Jul 5, 2023

Outdate pull request: #2464 #3827

@tiangolo
Copy link
Owner

tiangolo commented Jul 5, 2023

📝 Docs preview for commit 01e682a at: https://64a55e60c2150e06966d6dc5--fastapi.netlify.app

Copy link
Contributor

@mkdir700 mkdir700 left a comment

Choose a reason for hiding this comment

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

Some sentences have not been translated.

docs/zh/docs/tutorial/background-tasks.md Outdated Show resolved Hide resolved
docs/zh/docs/tutorial/background-tasks.md Outdated Show resolved Hide resolved
@tiangolo
Copy link
Owner

tiangolo commented Jul 6, 2023

📝 Docs preview for commit dbf65f9 at: https://64a6a9b09810b61cb9d3ec7e--fastapi.netlify.app

Copy link
Contributor

@mkdir700 mkdir700 left a comment

Choose a reason for hiding this comment

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

需要注意一下排版,中文与英文单词之间需要有空格占位。

例如:

使用BackgroundTasks
使用 BackgroundTasks


## 使用 `BackgroundTasks`

首先导入 `BackgroundTasks` 并在 *路径操作函数* 中使用类型声明`BackgroundTasks`定义一个参数:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
首先导入 `BackgroundTasks` 并在 *路径操作函数* 中使用类型声明`BackgroundTasks`定义一个参数:
首先导入 `BackgroundTasks` 并在 *路径操作函数* 中使用类型声明 `BackgroundTasks` 定义一个参数:

Copy link
Contributor Author

Choose a reason for hiding this comment

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


它被直接导入/包含到FastAPI以便你可以从 `fastapi` 导入,并避免意外从 `starlette.background` 导入备用的 `BackgroundTask` (后面没有 `s`)。

通过仅使用 `BackgroundTasks` (而不是 `BackgroundTask`),使得能将它作为 *路径操作函数* 的参数 ,并让**FastAPI**为您处理其余部分, 就像直接使用 `Request` 对象。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
通过仅使用 `BackgroundTasks` (而不是 `BackgroundTask`),使得能将它作为 *路径操作函数* 的参数 ,并让**FastAPI**为您处理其余部分, 就像直接使用 `Request` 对象。
通过仅使用 `BackgroundTasks` (而不是 `BackgroundTask`),使得能将它作为 *路径操作函数* 的参数 ,并让 **FastAPI** 为您处理其余部分, 就像直接使用 `Request` 对象。

Copy link
Contributor Author

@wdh99 wdh99 Jul 10, 2023

Choose a reason for hiding this comment

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

这里采用了加粗, 所以我认为可以不加空格


## 告诫

如果您需要执行繁重的后台计算,并且不一定需要由同一进程运行(例如,您不需要共享内存、变量等),那么使用其他更大的工具(如<a href="https://docs.celeryq.dev" class="external-link" target="_blank">Celery</a>)可能更好。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
如果您需要执行繁重的后台计算,并且不一定需要由同一进程运行(例如,您不需要共享内存、变量等),那么使用其他更大的工具(如<a href="https://docs.celeryq.dev" class="external-link" target="_blank">Celery</a>)可能更好。
如果您需要执行繁重的后台计算,并且不一定需要由同一进程运行(例如,您不需要共享内存、变量等),那么使用其他更大的工具(如 <a href="https://docs.celeryq.dev" class="external-link" target="_blank">Celery</a>)可能更好。

Copy link
Contributor Author

Choose a reason for hiding this comment

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


如果您需要执行繁重的后台计算,并且不一定需要由同一进程运行(例如,您不需要共享内存、变量等),那么使用其他更大的工具(如<a href="https://docs.celeryq.dev" class="external-link" target="_blank">Celery</a>)可能更好。

它们往往需要更复杂的配置,即消息/作业队列管理器,如RabbitMQ或Redis,但它们允许您在多个进程中运行后台任务,甚至是在多个服务器中。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
它们往往需要更复杂的配置,即消息/作业队列管理器,如RabbitMQ或Redis,但它们允许您在多个进程中运行后台任务,甚至是在多个服务器中。
它们往往需要更复杂的配置,即消息/作业队列管理器,如 RabbitMQ 或 Redis,但它们允许您在多个进程中运行后台任务,甚至是在多个服务器中。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里短短几个字加了好几个空格, 看起来有些凌乱, 所以我认为不用加空格.


它们往往需要更复杂的配置,即消息/作业队列管理器,如RabbitMQ或Redis,但它们允许您在多个进程中运行后台任务,甚至是在多个服务器中。

要查看示例,查阅 [Project Generators](../project-generation.md){.internal-link target=_blank},它们都包括已经配置的Celery。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
要查看示例,查阅 [Project Generators](../project-generation.md){.internal-link target=_blank},它们都包括已经配置的Celery
要查看示例,查阅 [Project Generators](../project-generation.md){.internal-link target=_blank},它们都包括已经配置的 Celery

Copy link
Contributor Author

Choose a reason for hiding this comment

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

英文单词出现在了最后面, 已经很清晰, 所以我认为不用加空格.


要查看示例,查阅 [Project Generators](../project-generation.md){.internal-link target=_blank},它们都包括已经配置的Celery。

但是,如果您需要从同一个**FastAPI**应用程序访问变量和对象,或者您需要执行小型后台任务(如发送电子邮件通知),您只需使用 `BackgroundTasks` 即可。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
但是,如果您需要从同一个**FastAPI**应用程序访问变量和对象,或者您需要执行小型后台任务(如发送电子邮件通知),您只需使用 `BackgroundTasks` 即可。
但是,如果您需要从同一个 **FastAPI** 应用程序访问变量和对象,或者您需要执行小型后台任务(如发送电子邮件通知),您只需使用 `BackgroundTasks` 即可。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里采用了加粗, 所以我认为可以不加空格

@Kludex Kludex added lang-all Translations lang-zh Chinese translations awaiting-review labels Jul 10, 2023
@tiangolo
Copy link
Owner

📝 Docs preview for commit ae21bcb at: https://64abec7fad158c06ddfd4636--fastapi.netlify.app

@tiangolo
Copy link
Owner

Great, thank you @wdh99! 🙇

And thanks for the reviews @mahone3297, @mkdir700, @lordqyxz, @ChoyeonChern 🍰

@tiangolo tiangolo merged commit e081145 into tiangolo:master Jul 27, 2023
35 checks passed
erosennin pushed a commit to erosennin/fastapi that referenced this pull request Jul 31, 2023
….md` (tiangolo#9812)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

None yet

7 participants