-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
30 lines (25 loc) · 910 Bytes
/
setup.py
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
import os
import subprocess
def create_mo_files():
data_files = []
localedir = "locale"
po_dirs = [
localedir + "/" + l + "/LC_MESSAGES/" for l in next(os.walk(localedir))[1]
]
for d in po_dirs:
mo_files = []
po_files = [f for f in next(os.walk(d))[2] if os.path.splitext(f)[1] == ".po"]
for po_file in po_files:
filename, extension = os.path.splitext(po_file)
mo_file = filename + ".mo"
msgfmt_cmd = "msgfmt {} -o {}".format(d + po_file, d + mo_file)
print("Executing: ", msgfmt_cmd, "...")
subprocess.call(msgfmt_cmd, shell=True)
mo_files.append(d + mo_file)
data_files.append((d, mo_files))
return data_files
if __name__ == "__main__":
mo_files = create_mo_files()
print("Created following .mo files:")
for _, mo_file in mo_files:
print(mo_file)