-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
update_translations.py
41 lines (29 loc) · 1.14 KB
/
update_translations.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
34
35
36
37
38
39
40
41
"""Update language files from ./locale"""
import os
import subprocess
import sys
from pathlib import Path
def main() -> None:
if not Path("pygettext.py").is_file():
print("ERROR: Please add a copy of pygettext.py to this dir from the Python Tools dir")
sys.exit()
locale_folder = "locale"
pot_path = Path(locale_folder) / "messages.pot"
print("Generate template")
subprocess.run(["python", "pygettext.py", "t_modules/t_dbus.py", "t_modules/t_extra.py", "t_modules/t_jellyfin.py", "t_modules/t_main.py", "t_modules/t_phazor.py", "t_modules/t_spot.py", "t_modules/t_stream.py", "t_modules/t_tidal.py", "t_modules/t_webserve.py"])
print("Copy template")
subprocess.run(["cp", "messages.pot", pot_path])
subprocess.run(["rm", "messages.pot"])
languages = os.listdir(locale_folder)
for lang_file in languages:
if lang_file == "messages.pot":
continue
po_path = Path(locale_folder) / lang_file / "LC_MESSAGES" / "tauon.po"
if Path(po_path).exists():
subprocess.run(["msgmerge", "-U", po_path, pot_path])
print(f"Updated: {lang_file}")
else:
print(f"Missing po file: {po_path}")
print("Done")
if __name__ == "__main__":
main()