Skip to content

Commit 3f65caa

Browse files
committed
Merge branch 'main' into assign-async-await
# Conflicts: # README.md
2 parents 9cb04e7 + 5e3ff54 commit 3f65caa

Some content is hidden

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

90 files changed

+982
-822
lines changed

.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` 字段。

.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

.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

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
-------------

CONTRIBUTING.md

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
## Contributing Guide
2+
3+
4+
### Installation
5+
6+
- Click the [Fork](https://github.com/greyli/flask-docs-zh/fork) button to fork this repository on GitHub.
7+
- Clone your fork repository locally (replace `{username}` with your username):
8+
9+
```
10+
$ git clone https://github.com/{username}/flask-docs-zh
11+
$ cd flask-docs-zh
12+
$ git remote add upstream https://github.com/greyli/flask-docs-zh
13+
```
14+
15+
- Create a virtual environment and install requirements:
16+
17+
For Linux/macOS:
18+
19+
```
20+
$ python3 -m venv env
21+
$ source env/bin/activate
22+
$ python -m pip install --upgrade pip setuptools
23+
$ pip install -r requirements/dev.txt
24+
$ pip install -e .
25+
$ pre-commit install
26+
```
27+
28+
For Windows:
29+
30+
```
31+
> python -m venv env
32+
> env\Scripts\activate
33+
> python -m pip install --upgrade pip setuptools
34+
> pip install -r .\requirements\dev.txt
35+
> pip install -e .
36+
> pre-commit install
37+
```
38+
39+
40+
### Self-Assignment
41+
42+
- Open your fork repository on GitHub.
43+
- Click the "Fetch upstream" button to update your fork.
44+
- Click the edit button (a pencil icon in the upper right corner of the README)
45+
to edit the README.
46+
- Find the "Translation To-do List" section, mark the chapter you want to
47+
translate in following format:
48+
49+
```
50+
- [ ] example @your_username Your Name
51+
```
52+
53+
You can link the username to your GitHub profile:
54+
55+
```
56+
- [ ] example [@your_username](https://github.com/your_username) Your Name
57+
```
58+
59+
- Leave a commit message (e.g., "Assign example to @your_username"), then select
60+
"Create a new branch for this commit and start a pull request" and click the
61+
"Commit changes" button to create a PR.
62+
63+
64+
### Translation
65+
66+
- When the self-assignment PR is merged, create a new branch locally
67+
(be sure to update the example branch name, for example, `translate-cli`):
68+
69+
```
70+
$ git fetch upstream
71+
$ git checkout -b your-branch-name upstream/main
72+
```
73+
74+
- Translate the `.po` file in the `docs/locales/zh_CN/LC_MESSAGES` directory.
75+
76+
An example of one such file, from docs/.../index.po, is given below.
77+
78+
```po
79+
#: ../../index.rst:4
80+
msgid "Welcome to Flask"
81+
msgstr "欢迎来到 Flask 的世界"
82+
```
83+
84+
Another case, msgid is multi-line text and contains reStructuredText syntax:
85+
86+
```po
87+
#: ../../index.rst:11
88+
msgid ""
89+
"Welcome to Flask's documentation. Get started with :doc:`installation` "
90+
"and then get an overview with the :doc:`quickstart`."
91+
msgstr ""
92+
"欢迎来到 Flask 的文档。你可以从 :doc:`installation` 入手"
93+
"然后阅读 :doc:`quickstart` 来了解基本概念。"
94+
```
95+
96+
Please be careful not to break reST notation. Most
97+
[po-editors](https://www.gnu.org/software/trans-coord/manual/web-trans/html_node/PO-Editors.html) will help you with that.
98+
99+
- Mark the chapter as finished (fill the checkbox with "x"):
100+
101+
```
102+
- [x] example @your_username Your Name
103+
```
104+
105+
- Update the `Last-Translator` field at the top of the `.po` file.
106+
- Commit the changes:
107+
108+
```
109+
$ git add docs/locales/zh_CN/LC_MESSAGES/example.po README.md
110+
$ git commit -m "Translate docs/example"
111+
```
112+
113+
- Build the docs and preview the changes:
114+
115+
For Linux/macOS:
116+
117+
```
118+
$ cd docs
119+
$ make html
120+
```
121+
122+
For Windows:
123+
124+
```
125+
> cd docs
126+
> .\make.bat html
127+
```
128+
129+
Open `{project_location}/docs/_build/html/index.html` in your browser to view the docs.
130+
131+
- If everything is working as expected, push the changes to GitHub:
132+
133+
```
134+
$ git push origin your-branch-name
135+
```
136+
137+
- Open the home page of your forked repository, you will see a notice about
138+
the new branch. Click the "Compare & pull request" button to create a PR.
139+
- The translation coordinator will review your PR very soon. Thank you!

0 commit comments

Comments
 (0)