openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.5 KiB

1 week ago
#!/usr/bin/env python3
1 week ago
from itertools import chain
1 week ago
import argparse
import json
import os
1 week ago
from openpilot.system.ui.lib.multilang import UI_DIR, TRANSLATIONS_DIR, LANGUAGES_FILE
1 week ago
def update_translations():
files = []
1 week ago
for root, _, filenames in chain(os.walk(os.path.join(UI_DIR, "widgets")),
7 days ago
os.walk(os.path.join(UI_DIR, "layouts")),
os.walk(os.path.join(UI_DIR, "onroad"))):
1 week ago
for filename in filenames:
if filename.endswith(".py"):
files.append(os.path.join(root, filename))
# Create main translation file
cmd = ("xgettext -L Python --keyword=tr --keyword=trn:1,2 --keyword=pgettext:1c,2 --from-code=UTF-8 " +
"--flag=tr:1:python-brace-format --flag=trn:1:python-brace-format --flag=trn:2:python-brace-format " +
"-o translations/app.pot {}").format(" ".join(files))
ret = os.system(cmd)
assert ret == 0
# Generate/update translation files for each language
with open(LANGUAGES_FILE) as f:
translation_files = json.load(f).values()
7 days ago
for name in translation_files:
1 week ago
if os.path.exists(os.path.join(TRANSLATIONS_DIR, f"app_{name}.po")):
1 week ago
cmd = f"msgmerge --update --backup=none --sort-output translations/app_{name}.po translations/app.pot"
1 week ago
ret = os.system(cmd)
assert ret == 0
else:
1 week ago
cmd = f"msginit -l {name} --no-translator --input translations/app.pot --output-file translations/app_{name}.po"
1 week ago
ret = os.system(cmd)
assert ret == 0
if __name__ == "__main__":
update_translations()