Skip to content

Commit ff250b1

Browse files
committed
Improve translation progress calculation
1 parent 5810295 commit ff250b1

File tree

2 files changed

+39
-84
lines changed

2 files changed

+39
-84
lines changed

trans_calculator.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

trans_progress.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
This repo get translation progress data
3+
from https://github.com/Jalkhov/docspro/tree/translation_data/data
4+
"""
5+
6+
import ast
7+
import json
8+
import urllib.request
9+
10+
import requests
11+
12+
uri = 'https://raw.githubusercontent.com/Jalkhov/docspro/translation_data/data/{lang}_cov.json'
13+
14+
class TranslatedProgress(object):
15+
16+
def __init__(self, repos):
17+
super(TranslatedProgress, self).__init__()
18+
self.repos = repos
19+
20+
def get_data(self):
21+
data = {}
22+
for lang in self.repos:
23+
data[lang] = self.get_cov(lang)
24+
25+
return data
26+
27+
def get_cov(self, lang):
28+
response = requests.get(uri.format(lang=lang)).text
29+
cov = json.loads(response)['cov']
30+
return cov
31+
32+
33+
def main():
34+
mu = TranslatedProgress(['es', 'fr', 'zh', 'fa'])
35+
data = mu.get_data()
36+
print(data)
37+
38+
if __name__ == '__main__':
39+
main()

0 commit comments

Comments
 (0)