From 7f439f03dd97eb832f2ff11d003cdcde478a4c51 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Thu, 3 Aug 2023 23:48:16 +0800 Subject: [PATCH 01/13] Add issue template --- .github/ISSUE_TEMPLATE/translation.yml | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/translation.yml diff --git a/.github/ISSUE_TEMPLATE/translation.yml b/.github/ISSUE_TEMPLATE/translation.yml new file mode 100644 index 000000000..6ed458362 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/translation.yml @@ -0,0 +1,46 @@ +name: Translation Issue Report +description: File a translation issue report +title: "[Typo]: " +labels: ["translation"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this translation issue report! + - type: input + id: version + attributes: + label: Python Version + description: Which version of Python docs contains the issue? + placeholder: ex. 3.12 + validations: + required: true + - type: input + id: url + attributes: + label: Docs Page + description: What is the url of the page contains the issue? + placeholder: https://docs.python.org/3/about.html + validations: + required: true + - type: textarea + id: zh-original + attributes: + label: Original Translation + description: Which translated paragraph in Chinese contains the issue? + validations: + required: true + - type: textarea + id: en-original + attributes: + label: Original Docs Paragraph + description: Which original paragraph in English contains the issue? + validations: + required: false + - type: textarea + id: zh-suggested + attributes: + label: Suggested Fix + description: What is you suggeest fix? + validations: + required: true \ No newline at end of file From 8530ab102ab2b282c5f079903e2526bba106887f Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 00:48:01 +0800 Subject: [PATCH 02/13] Add tx stat --- .github/scripts/tx_stat.py | 31 +++++++++++++++++++++++++++++++ .github/workflows/python-310.yml | 1 + .github/workflows/python-311.yml | 1 + .github/workflows/python-312.yml | 1 + .github/workflows/python-38.yml | 1 + .github/workflows/python-39.yml | 1 + .github/workflows/sync.yml | 8 ++++++++ 7 files changed, 44 insertions(+) create mode 100644 .github/scripts/tx_stat.py diff --git a/.github/scripts/tx_stat.py b/.github/scripts/tx_stat.py new file mode 100644 index 000000000..e9b2bf77b --- /dev/null +++ b/.github/scripts/tx_stat.py @@ -0,0 +1,31 @@ +import json +import os +import urllib.request + +key = os.environ.get('TX_TOKEN') +project = os.environ.get('TX_PROJECT') + +url = "https://rest.api.transifex.com/resource_language_stats?filter[project]=o%3Apython-doc%3Ap%3A{}&filter[language]=l%3Azh_CN".format(project) + +headers = { + "accept": "application/vnd.api+json", + "authorization": "Bearer " + key +} + +total = 0 +translated = 0 + +while(url): + request = urllib.request.Request(url=url,headers=headers) + + with urllib.request.urlopen(request) as response: + data = json.loads(response.read().decode("utf-8")) + url = data['links'].get('next') + for resourse in data['data']: + translated = translated + resourse['attributes']['translated_strings'] + total = total + resourse['attributes']['total_strings'] + +p = '{:.2%}'.format(translated/total) + +with open(".stat.json", "w") as text_file: + text_file.write(json.dumps({'translation':p})) \ No newline at end of file diff --git a/.github/workflows/python-310.yml b/.github/workflows/python-310.yml index 10e299b45..6607518d7 100644 --- a/.github/workflows/python-310.yml +++ b/.github/workflows/python-310.yml @@ -12,5 +12,6 @@ jobs: uses: ./.github/workflows/sync.yml with: version: "3.10" + tx_project: "python-310" secrets: inherit \ No newline at end of file diff --git a/.github/workflows/python-311.yml b/.github/workflows/python-311.yml index 3ac6cf1ba..9566d743f 100644 --- a/.github/workflows/python-311.yml +++ b/.github/workflows/python-311.yml @@ -12,5 +12,6 @@ jobs: uses: ./.github/workflows/sync.yml with: version: "3.11" + tx_project: "python-311" secrets: inherit diff --git a/.github/workflows/python-312.yml b/.github/workflows/python-312.yml index 228e64d78..d1bb99d95 100644 --- a/.github/workflows/python-312.yml +++ b/.github/workflows/python-312.yml @@ -12,4 +12,5 @@ jobs: uses: ./.github/workflows/sync.yml with: version: "3.12" + tx_project: "python-newest" secrets: inherit diff --git a/.github/workflows/python-38.yml b/.github/workflows/python-38.yml index e3725dc36..4da2959f9 100644 --- a/.github/workflows/python-38.yml +++ b/.github/workflows/python-38.yml @@ -12,4 +12,5 @@ jobs: uses: ./.github/workflows/sync.yml with: version: "3.8" + tx_project: "python-38" secrets: inherit \ No newline at end of file diff --git a/.github/workflows/python-39.yml b/.github/workflows/python-39.yml index 458459371..3d6e5da9a 100644 --- a/.github/workflows/python-39.yml +++ b/.github/workflows/python-39.yml @@ -12,5 +12,6 @@ jobs: uses: ./.github/workflows/sync.yml with: version: "3.9" + tx_project: "python-39" secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index a5a126e20..ad43bd164 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -6,6 +6,9 @@ on: version: required: true type: string + tx_project: + required: true + type: string secrets: TRANSIFEX_APIKEY: required: true @@ -37,5 +40,10 @@ jobs: TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }} - name: build run: .github/scripts/build.sh + - name: stat + run: cd ../docs && python ../.github/scripts/tx_stat.py + env: + TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }} + TX_PROJECT: ${{ inputs.tx_project }} - name: commit run: .github/scripts/commit.sh \ No newline at end of file From 77a36b1ad57b6432310adfbbf3b5b1d6366ed1d2 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:06:07 +0800 Subject: [PATCH 03/13] Update json output --- .github/scripts/tx_stat.py | 4 +--- .github/workflows/sync.yml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/scripts/tx_stat.py b/.github/scripts/tx_stat.py index e9b2bf77b..9b99b5d5d 100644 --- a/.github/scripts/tx_stat.py +++ b/.github/scripts/tx_stat.py @@ -26,6 +26,4 @@ total = total + resourse['attributes']['total_strings'] p = '{:.2%}'.format(translated/total) - -with open(".stat.json", "w") as text_file: - text_file.write(json.dumps({'translation':p})) \ No newline at end of file +print(json.dumps({'translation':p})) \ No newline at end of file diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index ad43bd164..d94640e4e 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -41,7 +41,7 @@ jobs: - name: build run: .github/scripts/build.sh - name: stat - run: cd ../docs && python ../.github/scripts/tx_stat.py + run: python .github/scripts/tx_stat.py > ../docs/.stat.json env: TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }} TX_PROJECT: ${{ inputs.tx_project }} From 94ebe6aff137d59a952df8406089aad9ee63c2c0 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:19:14 +0800 Subject: [PATCH 04/13] Fix dir path --- .github/workflows/sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index d94640e4e..3d2741421 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -41,7 +41,7 @@ jobs: - name: build run: .github/scripts/build.sh - name: stat - run: python .github/scripts/tx_stat.py > ../docs/.stat.json + run: python .github/scripts/tx_stat.py > ./docs/.stat.json env: TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }} TX_PROJECT: ${{ inputs.tx_project }} From af4aaaa438db04f3f1b8b12a93d61e8c06806b0b Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:48:50 +0800 Subject: [PATCH 05/13] Update readme badge --- README.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 3d791ca4a..5c38d3110 100644 --- a/README.rst +++ b/README.rst @@ -15,27 +15,27 @@ Maintained versions: * - `3.12 `_ - .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-312/badge.svg :target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-312 - - .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/312 + - .. image:: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpython%2Fpython-docs-zh-cn%2F3.12%2F.stat.json&query=%24.translation&label=zh-CN :target: https://app.transifex.com/python-doc/python-newest/ * - `3.11 `_ - .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-311/badge.svg :target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-311 - - .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/311 + - .. image:: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpython%2Fpython-docs-zh-cn%2F3.11%2F.stat.json&query=%24.translation&label=zh-CN :target: https://app.transifex.com/python-doc/python-311/ * - `3.10 `_ - .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-310/badge.svg :target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-310 - - .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/310 + - .. image:: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpython%2Fpython-docs-zh-cn%2F3.10%2F.stat.json&query=%24.translation&label=zh-CN :target: https://app.transifex.com/python-doc/python-310/ * - `3.9 `_ - .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-39/badge.svg :target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-39 - - .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/39 + - .. image:: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpython%2Fpython-docs-zh-cn%2F3.9%2F.stat.json&query=%24.translation&label=zh-CN :target: https://app.transifex.com/python-doc/python-39/ * - `3.8 `_ - .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-38/badge.svg :target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-38 - - .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/38 + - .. image:: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpython%2Fpython-docs-zh-cn%2F3.8%2F.stat.json&query=%24.translation&label=zh-CN :target: https://app.transifex.com/python-doc/python-38/ EOL versions: @@ -49,7 +49,7 @@ EOL versions: * - `3.7 `_ - .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-37/badge.svg :target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-37 - - .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/37 + - .. image:: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpython%2Fpython-docs-zh-cn%2F3.7%2F.stat.json&query=%24.translation&label=zh-CN :target: https://app.transifex.com/python-doc/python-37/ Documentation Contribution Agreement From 7b6788636ed32d7887aa26f75edca2807fa48563 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:54:31 +0800 Subject: [PATCH 06/13] Fix typo --- .github/ISSUE_TEMPLATE/translation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/translation.yml b/.github/ISSUE_TEMPLATE/translation.yml index 6ed458362..780ebc722 100644 --- a/.github/ISSUE_TEMPLATE/translation.yml +++ b/.github/ISSUE_TEMPLATE/translation.yml @@ -11,7 +11,7 @@ body: id: version attributes: label: Python Version - description: Which version of Python docs contains the issue? + description: Which version of the Python documentation covers this issue? placeholder: ex. 3.12 validations: required: true @@ -19,7 +19,7 @@ body: id: url attributes: label: Docs Page - description: What is the url of the page contains the issue? + description: What is the url of the page containing the issue? placeholder: https://docs.python.org/3/about.html validations: required: true @@ -41,6 +41,6 @@ body: id: zh-suggested attributes: label: Suggested Fix - description: What is you suggeest fix? + description: What is your suggested fix? validations: required: true \ No newline at end of file From 156beca61c07ccad1730b89a2a6424c3c6dfd958 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:11:55 +0800 Subject: [PATCH 07/13] Add update time --- .github/scripts/tx_stat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/scripts/tx_stat.py b/.github/scripts/tx_stat.py index 9b99b5d5d..00dcf965c 100644 --- a/.github/scripts/tx_stat.py +++ b/.github/scripts/tx_stat.py @@ -1,6 +1,7 @@ import json import os import urllib.request +from datetime import datetime key = os.environ.get('TX_TOKEN') project = os.environ.get('TX_PROJECT') @@ -26,4 +27,7 @@ total = total + resourse['attributes']['total_strings'] p = '{:.2%}'.format(translated/total) -print(json.dumps({'translation':p})) \ No newline at end of file +print(json.dumps({ + 'translation':p, + 'updated_at':datetime.utcnow().isoformat(timespec='seconds') + 'Z', + })) \ No newline at end of file From 6dd2503418aadb5c7239c37557ecf02905487481 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:25:48 +0800 Subject: [PATCH 08/13] Add cache layer --- .github/workflows/sync.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 3d2741421..83a51080a 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -38,8 +38,17 @@ jobs: run: .github/scripts/update.sh env: TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }} + - uses: actions/cache/restore@v3 + with: + path: cpython/Doc/build + key: cache-${{ inputs.version }}-${{ github.run_id }} + restore-keys: cache-${{ inputs.version }}- - name: build run: .github/scripts/build.sh + - uses: actions/cache/save@v3 + with: + path: cpython/Doc/build + key: cache-${{ inputs.version }}-${{ github.run_id }} - name: stat run: python .github/scripts/tx_stat.py > ./docs/.stat.json env: From 3dff8381d7134705e628fabbbb72ecce0805520d Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:53:12 +0800 Subject: [PATCH 09/13] Restore git timestamp for enabling build cache --- .github/scripts/update.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/scripts/update.sh b/.github/scripts/update.sh index d2f6f13be..c2f237935 100755 --- a/.github/scripts/update.sh +++ b/.github/scripts/update.sh @@ -1,4 +1,21 @@ #!/bin/bash cd docs || exit 1 + +# Restore git timestamp for enabling build cache +if [ $# = 0 ]; then + git ls-files -z |xargs -0 sh "$0" + exit $? +fi + +for file in "$@"; do + time="$(git log --pretty=format:%cd -n 1 \ + --date=format:%Y%m%d%H%M.%S --date-order -- "$file")" + if [ -z "$time" ]; then + echo "ERROR: skipping '$file' -- no git log found" >&2 + continue + fi + touch -m -t "$time" "$file" +done + $(realpath ../tx) pull --languages "$LOCALE" -t --use-git-timestamps --workers 25 --silent From 2896f1d65ec71ee1d28642b558d22aa0f7e3ac30 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:05:57 +0800 Subject: [PATCH 10/13] Restore git timestamp with another method --- .github/scripts/update.sh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/scripts/update.sh b/.github/scripts/update.sh index c2f237935..f13ac9153 100755 --- a/.github/scripts/update.sh +++ b/.github/scripts/update.sh @@ -3,19 +3,9 @@ cd docs || exit 1 # Restore git timestamp for enabling build cache -if [ $# = 0 ]; then - git ls-files -z |xargs -0 sh "$0" - exit $? -fi - -for file in "$@"; do - time="$(git log --pretty=format:%cd -n 1 \ - --date=format:%Y%m%d%H%M.%S --date-order -- "$file")" - if [ -z "$time" ]; then - echo "ERROR: skipping '$file' -- no git log found" >&2 - continue - fi - touch -m -t "$time" "$file" +rev=HEAD +for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do + touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f"; done $(realpath ../tx) pull --languages "$LOCALE" -t --use-git-timestamps --workers 25 --silent From 7e2b982ea576e229f0ced6016f74b67869be021f Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:17:33 +0800 Subject: [PATCH 11/13] Restore git timestamp --- .github/scripts/update.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/scripts/update.sh b/.github/scripts/update.sh index f13ac9153..5c4335c88 100755 --- a/.github/scripts/update.sh +++ b/.github/scripts/update.sh @@ -1,5 +1,14 @@ #!/bin/bash +cd cpython || exit 1 + +# Restore git timestamp for enabling build cache +rev=HEAD +for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do + touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f"; +done + +cd .. cd docs || exit 1 # Restore git timestamp for enabling build cache From a2f1df8d831551be6f949447adf98623bf41ce91 Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:55:44 +0800 Subject: [PATCH 12/13] Update only Doc dir --- .github/scripts/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/update.sh b/.github/scripts/update.sh index 5c4335c88..4a15d3095 100755 --- a/.github/scripts/update.sh +++ b/.github/scripts/update.sh @@ -4,7 +4,7 @@ cd cpython || exit 1 # Restore git timestamp for enabling build cache rev=HEAD -for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do +for f in $(git ls-tree -r -t --full-name --name-only "$rev" Doc) ; do touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f"; done From 3c9860ec36c4bce441702b972a346f3585b1d7bc Mon Sep 17 00:00:00 2001 From: A <5249513+Dumeng@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:08:26 +0800 Subject: [PATCH 13/13] Run dummy build instead --- .github/scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh index 2cbcb8e11..4e9b1556c 100755 --- a/.github/scripts/build.sh +++ b/.github/scripts/build.sh @@ -14,4 +14,4 @@ cd cpython/Doc || exit 1 mkdir -p locales/"$LOCALE"/ ln -sfn "$(realpath ../../docs)" locales/"$LOCALE"/LC_MESSAGES pip3 install -q -r requirements.txt -make html SPHINXOPTS="-D language=$LOCALE -D gettext_compact=0 -W --keep-going" 2> >(error) +sphinx-build -b dummy -d build/doctrees -j auto -D language=$LOCALE -D gettext_compact=0 -W --keep-going -W . build/html 2> >(error) \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy