File tree Expand file tree Collapse file tree 7 files changed +44
-0
lines changed Expand file tree Collapse file tree 7 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ import json
2
+ import os
3
+ import urllib .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
+ with urllib .request .urlopen (request ) as response :
22
+ data = json .loads (response .read ().decode ("utf-8" ))
23
+ url = data ['links' ].get ('next' )
24
+ for resourse in data ['data' ]:
25
+ translated = translated + resourse ['attributes' ]['translated_strings' ]
26
+ total = total + resourse ['attributes' ]['total_strings' ]
27
+
28
+ p = '{:.2%}' .format (translated / total )
29
+
30
+ with open (".stat.json" , "w" ) as text_file :
31
+ text_file .write (json .dumps ({'translation' :p }))
Original file line number Diff line number Diff line change 12
12
uses : ./.github/workflows/sync.yml
13
13
with :
14
14
version : " 3.10"
15
+ tx_project : " python-310"
15
16
secrets : inherit
16
17
Original file line number Diff line number Diff line change 12
12
uses : ./.github/workflows/sync.yml
13
13
with :
14
14
version : " 3.11"
15
+ tx_project : " python-311"
15
16
secrets : inherit
16
17
Original file line number Diff line number Diff line change 12
12
uses : ./.github/workflows/sync.yml
13
13
with :
14
14
version : " 3.12"
15
+ tx_project : " python-newest"
15
16
secrets : inherit
Original file line number Diff line number Diff line change 12
12
uses : ./.github/workflows/sync.yml
13
13
with :
14
14
version : " 3.8"
15
+ tx_project : " python-38"
15
16
secrets : inherit
Original file line number Diff line number Diff line change 12
12
uses : ./.github/workflows/sync.yml
13
13
with :
14
14
version : " 3.9"
15
+ tx_project : " python-39"
15
16
secrets : inherit
16
17
Original file line number Diff line number Diff line change 6
6
version :
7
7
required : true
8
8
type : string
9
+ tx_project :
10
+ required : true
11
+ type : string
9
12
secrets :
10
13
TRANSIFEX_APIKEY :
11
14
required : true
37
40
TX_TOKEN : ${{ secrets.TRANSIFEX_APIKEY }}
38
41
- name : build
39
42
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 }}
40
48
- name : commit
41
49
run : .github/scripts/commit.sh
You can’t perform that action at this time.
0 commit comments