Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8530ab1

Browse files
authored
Add tx stat
1 parent7f439f0 commit8530ab1

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

‎.github/scripts/tx_stat.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
importjson
2+
importos
3+
importurllib.request
4+
5+
key=os.environ.get('TX_TOKEN')
6+
project=os.environ.get('TX_PROJECT')
7+
8+
url="https://rest.api.transifex.com/resource_language_stats?filter[project]=o%3Apython-doc%3Ap%3A{}&filter[language]=l%3Azh_CN".format(project)
9+
10+
headers= {
11+
"accept":"application/vnd.api+json",
12+
"authorization":"Bearer "+key
13+
}
14+
15+
total=0
16+
translated=0
17+
18+
while(url):
19+
request=urllib.request.Request(url=url,headers=headers)
20+
21+
withurllib.request.urlopen(request)asresponse:
22+
data=json.loads(response.read().decode("utf-8"))
23+
url=data['links'].get('next')
24+
forresourseindata['data']:
25+
translated=translated+resourse['attributes']['translated_strings']
26+
total=total+resourse['attributes']['total_strings']
27+
28+
p='{:.2%}'.format(translated/total)
29+
30+
withopen(".stat.json","w")astext_file:
31+
text_file.write(json.dumps({'translation':p}))

‎.github/workflows/python-310.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ jobs:
1212
uses:./.github/workflows/sync.yml
1313
with:
1414
version:"3.10"
15+
tx_project:"python-310"
1516
secrets:inherit
1617

‎.github/workflows/python-311.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ jobs:
1212
uses:./.github/workflows/sync.yml
1313
with:
1414
version:"3.11"
15+
tx_project:"python-311"
1516
secrets:inherit
1617

‎.github/workflows/python-312.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ jobs:
1212
uses:./.github/workflows/sync.yml
1313
with:
1414
version:"3.12"
15+
tx_project:"python-newest"
1516
secrets:inherit

‎.github/workflows/python-38.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ jobs:
1212
uses:./.github/workflows/sync.yml
1313
with:
1414
version:"3.8"
15+
tx_project:"python-38"
1516
secrets:inherit

‎.github/workflows/python-39.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ jobs:
1212
uses:./.github/workflows/sync.yml
1313
with:
1414
version:"3.9"
15+
tx_project:"python-39"
1516
secrets:inherit
1617

‎.github/workflows/sync.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
version:
77
required:true
88
type:string
9+
tx_project:
10+
required:true
11+
type:string
912
secrets:
1013
TRANSIFEX_APIKEY:
1114
required:true
@@ -37,5 +40,10 @@ jobs:
3740
TX_TOKEN:${{ secrets.TRANSIFEX_APIKEY }}
3841
-name:build
3942
run:.github/scripts/build.sh
43+
-name:stat
44+
run:cd ../docs && python ../.github/scripts/tx_stat.py
45+
env:
46+
TX_TOKEN:${{ secrets.TRANSIFEX_APIKEY }}
47+
TX_PROJECT:${{ inputs.tx_project }}
4048
-name:commit
4149
run:.github/scripts/commit.sh

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp