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 diff --git a/.github/scripts/tx_stat.py b/.github/scripts/tx_stat.py new file mode 100644 index 000000000..00dcf965c --- /dev/null +++ b/.github/scripts/tx_stat.py @@ -0,0 +1,33 @@ +import json +import os +import urllib.request +from datetime import datetime + +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) +print(json.dumps({ + 'translation':p, + 'updated_at':datetime.utcnow().isoformat(timespec='seconds') + 'Z', + })) \ 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..3d2741421 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: python .github/scripts/tx_stat.py > ./docs/.stat.json + env: + TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }} + TX_PROJECT: ${{ inputs.tx_project }} - name: commit run: .github/scripts/commit.sh \ No newline at end of file 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