-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_mo.py
33 lines (28 loc) · 1.19 KB
/
generate_mo.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
31
32
33
from os import path, system, chdir, listdir, getcwd
from sys import platform, argv
def generate_mo_files():
chdir(path.dirname(argv[0]))
system_code = 0
for directory in listdir():
if path.isdir(directory):
chdir(path.join(getcwd(), directory, "LC_MESSAGES"))
if platform == "linux" or platform == "linux2" or platform == "darwin":
system_code = system("msgfmt -o lang.mo lang")
elif platform == "win32":
system_code = system(f"python ..\\..\\msgfmt.py -o lang.mo lang")
if system_code != 0:
return system_code
chdir("../..")
print("Made lang.mo files!")
if __name__ == '__main__':
if platform == "win32":
generate_mo_files()
elif platform == "linux" or platform == "linux2" or platform == "darwin":
code = generate_mo_files()
if code is not None:
if platform != "darwin":
print("Check if you have gettext installed\nTo install: 'sudo apt install gettext'")
else:
print("Check if you have gettext installed\nTo install: 'brew install gettext'")
else:
print("Your system is unknown")