Skip to content

Commit 957c3c8

Browse files
authored
Merge branch 'main' into translate-async-await
2 parents 1f8954e + 839aa8e commit 957c3c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+846
-683
lines changed

Diff for: .github/pull_request_template.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<!--
2-
Before opening a PR, make sure you have claimed to translate a file by
3-
adding your username after the file entry in the README.
2+
如果这个 PR 是认领某个要翻译的章节,那么可以删除这个 PR 模板的所有内容。
43
-->
54

65
<!--
7-
Link to relevant issues or previous PRs, one per line. Use "fixes" to
8-
automatically close an issue.
6+
如果有不确定的翻译,请在这里逐条注明并替换这个注释。你也可以在 Discussion 创建讨论。
97
-->
108

11-
- fixes #<issue number>
129

1310
<!--
14-
Ensure each step in the "Contrubuting Guide" of the README is complete by
15-
adding an "x" to each box below.
11+
如果你的 PR 是要处理某个 issue,请把下面的 `<issue number>` 替换为对应的 issue 编号。如果没有的话,可以删除下面这一行。
1612
-->
1713

18-
Checklist:
14+
- fixes #<issue number>
15+
16+
<!--
17+
对于翻译 PR,确保你已经完整阅读 README.md 里的《Contrubuting Guide》小节和置顶 issue《翻译要求与建议》。完成并勾选下面的检查清单(把方括号里的空格替换为 `x`)。
18+
-->
1919

20-
- [ ] Fill the checkbox of the related file entry in the README with an "x".
21-
- [ ] Run `pre-commit` hooks and fix any issues.
22-
- [ ] Build docs locally, no warnings or errors.
20+
- [ ] 在 README.md 中勾选翻译的章节条目(把方括号里的空格替换为 `x`).
21+
- [ ] 在本地生成文档并预览输出,处理所有错误和异常。
22+
- [ ] 运行 `pre-commit` 钩子,处理所有问题。
23+
- [ ] 更新 `.po` 文件顶部的 `Last-Translator` 字段。

Diff for: .github/workflows/sync.yaml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Sync
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 19 * * *" # Run at 3am UTF+8 every day
7+
8+
jobs:
9+
sync:
10+
name: Sync with upstream docs
11+
runs-on: ubuntu-latest
12+
continue-on-error: true
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: actions/setup-python@v2
19+
with:
20+
python-version: 3.9
21+
22+
- name: Fetch upstream changes
23+
id: fetch-changes
24+
run: |
25+
git config --local user.email "[email protected]"
26+
git config --local user.name "GitHub Action"
27+
git remote add upstream https://github.com/pallets/flask.git
28+
git fetch upstream
29+
git merge upstream/2.0.x -m "Merge upstream changes into 'main' by GitHub Actions"
30+
# If docs/ has changes, continue below steps otherwise abort
31+
git diff --name-only origin/main HEAD | grep -q -e '^docs/'
32+
33+
- name: Generate Translation
34+
run: |
35+
pip install -r requirements/docs.txt
36+
pip install PyGithub
37+
pip install -e .
38+
cd docs
39+
make gettext
40+
sphinx-intl update -p _build/gettext
41+
cd ..
42+
git add docs/
43+
git commit -m "Update po files by GitHub Actions"
44+
45+
- name: Push changes
46+
uses: ad-m/github-push-action@master
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Create issue
51+
shell: python
52+
run: |
53+
import subprocess, os
54+
from datetime import datetime
55+
from github import Github
56+
current_date = datetime.today().strftime(' %Y-%m-%d')
57+
g = Github(os.getenv('GITHUB_TOKEN'))
58+
changed = subprocess.check_output("git diff --name-only HEAD~1 HEAD | grep -e '^docs/locales/'", shell=True, text=True)
59+
body = "## Changed po files\n\n" + "\n".join(f"- [ ] {line}" for line in changed.splitlines() if line.strip())
60+
repo = g.get_repo(os.getenv('REPO'))
61+
label = repo.get_label('sync')
62+
issue = repo.create_issue(title=os.getenv('ISSUE_TITLE') + current_date, body=body, labels=[label])
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
REPO: ${{ github.repository }}
66+
ISSUE_TITLE: Sync translation for upstream updates

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ htmlcov/
2424
.coverage
2525
.coverage.*
2626
*,cover
27+
28+
# Translation
29+
*.mo

Diff for: CHANGES.rst

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Version 2.0.2
1313

1414
Unreleased
1515

16+
- Fix type annotation for ``teardown_request``. :issue:`4093`
17+
- Fix type annotation for ``before_request`` and ``before_app_request``
18+
decorators. :issue:`4104`
19+
- Fixed the issue where typing requires template global
20+
decorators to accept functions with no arguments. :issue:`4098`
21+
1622

1723
Version 2.0.1
1824
-------------

Diff for: README.md

+23-32
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# Flask Docs Translation
1+
# Flask 中文文档
22

3-
这里是 Flask 文档中文翻译项目,欢迎参与!在开始翻译之前,请务必阅读下面的 Contributing Guide 了解贡献流程,然后阅读[这个 Issue](https://github.com/greyli/flask-docs-zh/issues/11) 了解翻译基本要求和建议,并在[这个 Dicussion](https://github.com/greyli/flask-docs-zh/discussions/12) 投票选出你认为合适的翻译词汇。
3+
这里是 Flask 文档中文翻译项目,欢迎参与!
44

5-
如果有其他问题和相关想法,请[创建 Discussion](https://github.com/greyli/flask-docs-zh/discussions/new) 发起讨论;如果对翻译流程和项目设置有改进建议,或是发现了翻译错误和笔误,请[创建 Issue](https://github.com/greyli/flask-docs-zh/issues/new) 反馈。
5+
1. 在开始翻译之前,请务必阅读下面的 Contributing Guide 了解翻译流程,然后阅读[这个 issue](https://github.com/greyli/flask-docs-zh/issues/11) 了解翻译要求,并在[这些 discussions](https://github.com/greyli/flask-docs-zh/discussions/categories/vote) 中分别投票选出最佳翻译词汇、中文 logo 字体和中文标语。
6+
2. 需要强调的是,完成一章的翻译要提交两个 PR:第一个 PR 在对应的章节条目后添加自己的用户名以认领章节;第二个 PR 翻译对应的 `.po` 文件并勾选完成的章节条目。先认领,再翻译,一次只认领一章。
7+
3. 不要改动任何 ReStructuredText 标记、变量/类/函数/方法名称、URL 等。
68

7-
这个项目在后期会转移到 [Flask Community Work Group](https://github.com/flaskcwg) 组织,并链接到 Flask 官方文档作为官方中文翻译。
9+
如果有其他问题和相关想法,请[创建 discussion](https://github.com/greyli/flask-docs-zh/discussions/new) 发起讨论;如果对翻译流程和项目设置有改进建议,或是发现了翻译错误和笔误,请[创建 issue](https://github.com/greyli/flask-docs-zh/issues/new) 反馈。
10+
11+
这个项目在后期会转移到 [FlaskCWG](https://github.com/flaskcwg) 组织,并在翻译完成后链接到 Flask 官方文档。
812

913

1014
## Contributing Guide
@@ -87,7 +91,7 @@ An example of one such file, from docs/.../index.po, is given below.
8791
```po
8892
#: ../../index.rst:4
8993
msgid "Welcome to Flask"
90-
msgstr "<FILL HERE BY TARGET LANGUAGE>"
94+
msgstr "欢迎来到 Flask 的世界"
9195
```
9296

9397
Another case, msgid is multi-line text and contains reStructuredText syntax:
@@ -98,11 +102,12 @@ msgid ""
98102
"Welcome to Flask's documentation. Get started with :doc:`installation` "
99103
"and then get an overview with the :doc:`quickstart`."
100104
msgstr ""
101-
"FILL HERE BY TARGET LANGUAGE FILL HERE BY TARGET LANGUAGE :doc:`installation` "
102-
"FILL HERE BY TARGET LANGUAGE :doc:`quickstart`."
105+
"欢迎来到 Flask 的文档。你可以从 :doc:`installation` 入手"
106+
"然后阅读 :doc:`quickstart` 来了解基本概念。"
103107
```
104108

105-
Please be careful not to break reST notation. Most po-editors will help you with that.
109+
Please be careful not to break reST notation. Most
110+
[po-editors](https://www.gnu.org/software/trans-coord/manual/web-trans/html_node/PO-Editors.html) will help you with that.
106111

107112
- Mark the chapter as finished (fill the checkbox with "x"):
108113

@@ -147,20 +152,6 @@ the new branch. Click the "Compare & pull request" button to create a PR.
147152
- The translation coordinator will review your PR very soon. Thank you!
148153

149154

150-
### Tips
151-
152-
**If you use translator.** Do not put the whole content of a file into the
153-
translator, this can cause problems with code snippets, reserved words of the
154-
programming language, special ReStructuredText tags and so on, the best way is to
155-
translate paragraph by paragraph, header by header.
156-
157-
**Maintaining the essence.** Although the translator does a large part of the work,
158-
sometimes the resulting translation does not match the meaning of the original
159-
resource. It is important to correct this so that the original meaning is not lost.
160-
Do not change names of functions, classes, variables methods etc in the codes, it
161-
is possible that they will stop working.
162-
163-
164155
## Translation To-do List
165156

166157
Be sure only mark one chapter at a time, mark another one when the former
@@ -171,29 +162,29 @@ if you doesn't finish the translation in ten days.
171162
### docs/
172163

173164
- [ ] advanced_foreword (reserved)
174-
- [ ] appcontext
165+
- [ ] appcontext [@rosekc](https://github.com/rosekc) rosekc
175166
- [x] async-await [@rosekc](https://github.com/rosekc) rosekc
176167
- [ ] becomingbig
177-
- [ ] blueprints
168+
- [x] blueprints [@frostming](https://github.com/frostming) Frost Ming
178169
- [ ] changes
179170
- [ ] cli
180-
- [ ] config
171+
- [ ] config [@guiqiqi](https://github.com/guiqiqi) Doge-GUI
181172
- [ ] contributing
182173
- [ ] debugging
183174
- [ ] design
184-
- [ ] errorhandling
175+
- [ ] errorhandling [@qiufengyu](https://github.com/qiufengyu) Fengyu
185176
- [ ] extensiondev
186177
- [ ] extensions
187178
- [ ] foreword (reserved)
188179
- [ ] htmlfaq
189-
- [ ] index (reserved)
190-
- [ ] installation (reserved)
180+
- [x] index [@greyli](https://github.com/greyli) Grey Li
181+
- [x] installation [@greyli](https://github.com/greyli) Grey Li
191182
- [ ] logging
192183
- [ ] quickstart (reserved)
193-
- [ ] reqcontext
184+
- [ ] reqcontext [@rosekc](https://github.com/rosekc) rosekc
194185
- [ ] security
195186
- [ ] server
196-
- [ ] shell
187+
- [ ] shell [@LTakamori](https://github.com/LTakamori) LTakamori
197188
- [ ] signals
198189
- [ ] templating
199190
- [ ] testing
@@ -206,7 +197,7 @@ if you doesn't finish the translation in ten days.
206197
- [ ] database
207198
- [ ] deploy
208199
- [ ] factory
209-
- [ ] index
200+
- [x] index [@greyli](https://github.com/greyli) Grey Li
210201
- [ ] install
211202
- [ ] layout
212203
- [ ] next
@@ -221,7 +212,7 @@ if you doesn't finish the translation in ten days.
221212
- [ ] asgi
222213
- [ ] cgi
223214
- [ ] fastcgi
224-
- [ ] index
215+
- [ ] index [@180909](https://github.com/180909) 180909
225216
- [ ] mod_wsgi
226217
- [ ] uwsgi
227218
- [ ] wsgi-standalone

Diff for: docs/_static/flask-logo.png

7.43 KB
Loading

Diff for: docs/async-await.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Using ``async`` and ``await``
77

88
Routes, error handlers, before request, after request, and teardown
99
functions can all be coroutine functions if Flask is installed with the
10-
``async`` extra (``pip install flask[async]``). This allows views to be
10+
``async`` extra (``pip install flask[async]``). It requires Python 3.7+
11+
where ``contextvars.ContextVar`` is available. This allows views to be
1112
defined with ``async def`` and use ``await``.
1213

1314
.. code-block:: python

Diff for: docs/conf.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
html_theme_options = {"index_sidebar_logo": False}
4040
html_context = {
4141
"project_links": [
42-
ProjectLink("Donate", "https://palletsprojects.com/donate"),
42+
ProjectLink("捐赠", "https://palletsprojects.com/donate"),
4343
ProjectLink("PyPI Releases", "https://pypi.org/project/Flask/"),
44-
ProjectLink("Source Code", "https://github.com/pallets/flask/"),
44+
ProjectLink("源码", "https://github.com/pallets/flask/"),
4545
ProjectLink("Issue Tracker", "https://github.com/pallets/flask/issues/"),
46-
ProjectLink("Website", "https://palletsprojects.com/p/flask/"),
46+
ProjectLink("网站", "https://palletsprojects.com/p/flask/"),
4747
ProjectLink("Twitter", "https://twitter.com/PalletsTeam"),
48-
ProjectLink("Chat", "https://discord.gg/pallets"),
48+
ProjectLink("聊天", "https://discord.gg/pallets"),
49+
ProjectLink("参与翻译", "https://github.com/greyli/flask-docs-zh"),
4950
]
5051
}
5152
html_sidebars = {
@@ -56,7 +57,7 @@
5657
html_static_path = ["_static"]
5758
html_favicon = "_static/flask-icon.png"
5859
html_logo = "_static/flask-icon.png"
59-
html_title = f"Flask Documentation ({version})"
60+
html_title = f"Flask 文档 ({version})"
6061
html_show_sourcelink = False
6162

6263
# LaTeX ----------------------------------------------------------------
@@ -100,7 +101,7 @@ def setup(app):
100101

101102
# Translation ----------------------------------------------------------
102103

103-
locale_dirs = ['locales'] # path is example but recommended.
104-
gettext_compact = False # optional.
105-
# see https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language
106-
language = '' # update this
104+
locale_dirs = ["locales"]
105+
gettext_compact = False
106+
language = "zh_CN"
107+
html_search_language = "zh"

Diff for: docs/installation.rst

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Python Version
88
We recommend using the latest version of Python. Flask supports Python
99
3.6 and newer.
1010

11+
``async`` support in Flask requires Python 3.7+ for ``contextvars.ContextVar``.
12+
1113

1214
Dependencies
1315
------------

Diff for: docs/locales/zh_CN/LC_MESSAGES/advanced_foreword.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ msgstr ""
1111
"POT-Creation-Date: 2021-05-25 19:31+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14-
"Language-Team: LANGUAGE <[email protected]>\n"
14+
"Language-Team: zh_CN <[email protected]>\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"

Diff for: docs/locales/zh_CN/LC_MESSAGES/api.po

+18-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Flask 2.1.x\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-05-25 19:31+0800\n"
11+
"POT-Creation-Date: 2021-05-30 19:27+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14-
"Language-Team: LANGUAGE <[email protected]>\n"
14+
"Language-Team: zh_CN <[email protected]>\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
@@ -242,7 +242,7 @@ msgstr ""
242242
#: werkzeug.wrappers.response.Response.get_wsgi_response
243243
#: werkzeug.wrappers.response.Response.make_conditional
244244
#: werkzeug.wrappers.response.Response.set_data
245-
msgid "Parameters"
245+
msgid "参数"
246246
msgstr ""
247247

248248
#: flask.app.Flask:66 of
@@ -453,7 +453,7 @@ msgstr ""
453453
#: werkzeug.wrappers.response.Response.make_conditional
454454
#: werkzeug.wrappers.response.Response.make_sequence
455455
#: werkzeug.wrappers.response.Response.set_data
456-
msgid "Return type"
456+
msgid "返回类型"
457457
msgstr ""
458458

459459
#: flask.app.Flask.add_template_global:1 of
@@ -1407,7 +1407,7 @@ msgstr ""
14071407
#: werkzeug.wrappers.response.Response.get_app_iter
14081408
#: werkzeug.wrappers.response.Response.get_wsgi_headers
14091409
#: werkzeug.wrappers.response.Response.get_wsgi_response
1410-
msgid "Returns"
1410+
msgid "返回"
14111411
msgstr ""
14121412

14131413
#: flask.app.Flask.process_response:10 of
@@ -5303,7 +5303,7 @@ msgid ""
53035303
msgstr ""
53045304

53055305
#: flask.json.tag.TaggedJSONSerializer.register of
5306-
msgid "Raises"
5306+
msgid "引发"
53075307
msgstr ""
53085308

53095309
#: flask.json.tag.TaggedJSONSerializer.register:11 of
@@ -6602,3 +6602,15 @@ msgid ""
66026602
"having to manually configure the application."
66036603
msgstr ""
66046604

6605+
#~ msgid "Parameters"
6606+
#~ msgstr ""
6607+
6608+
#~ msgid "Return type"
6609+
#~ msgstr ""
6610+
6611+
#~ msgid "Returns"
6612+
#~ msgstr ""
6613+
6614+
#~ msgid "Raises"
6615+
#~ msgstr ""
6616+

Diff for: docs/locales/zh_CN/LC_MESSAGES/appcontext.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ msgstr ""
1111
"POT-Creation-Date: 2021-05-25 19:31+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14-
"Language-Team: LANGUAGE <[email protected]>\n"
14+
"Language-Team: zh_CN <[email protected]>\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"

0 commit comments

Comments
 (0)