forked from spesmilo/electrum-locale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·34 lines (28 loc) · 891 Bytes
/
update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import os
import io
import zipfile
import requests
os.chdir(os.path.dirname(os.path.realpath(__file__)))
# Download & unzip
print('Download translations')
s = requests.request('GET', 'https://crowdin.com/backend/download/project/electrumsys.zip').content
zfobj = zipfile.ZipFile(io.BytesIO(s))
print('Unzip translations')
for name in zfobj.namelist():
if not name.startswith('electrumsys-client/locale'):
continue
if name.endswith('/'):
if not os.path.exists(name[16:]):
os.mkdir(name[16:])
else:
with open(name[16:], 'wb') as output:
output.write(zfobj.read(name))
# Convert .po to .mo
print('Installing')
for lang in os.listdir('locale'):
po = 'locale/%s/electrumsys.po' % lang
cmd = "git add %s"%po
os.system(cmd)
os.system("git commit -a -m 'update translations'")
print("please push")