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 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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 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