mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
+227
-246
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
from itertools import chain
|
||||
import os
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.system.ui.lib.multilang import SYSTEM_UI_DIR, UI_DIR, TRANSLATIONS_DIR, multilang
|
||||
|
||||
POT_FILE = os.path.join(TRANSLATIONS_DIR, "app.pot")
|
||||
|
||||
|
||||
def update_translations():
|
||||
files = []
|
||||
@@ -12,12 +15,12 @@ def update_translations():
|
||||
os.walk(os.path.join(UI_DIR, "onroad"))):
|
||||
for filename in filenames:
|
||||
if filename.endswith(".py"):
|
||||
files.append(os.path.join(root, filename))
|
||||
files.append(os.path.relpath(os.path.join(root, filename), BASEDIR))
|
||||
|
||||
# Create main translation file
|
||||
cmd = ("xgettext -L Python --keyword=tr --keyword=trn:1,2 --keyword=tr_noop --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))
|
||||
f"-D {BASEDIR} -o {POT_FILE} {' '.join(files)}")
|
||||
|
||||
ret = os.system(cmd)
|
||||
assert ret == 0
|
||||
@@ -25,11 +28,11 @@ def update_translations():
|
||||
# Generate/update translation files for each language
|
||||
for name in multilang.languages.values():
|
||||
if os.path.exists(os.path.join(TRANSLATIONS_DIR, f"app_{name}.po")):
|
||||
cmd = f"msgmerge --update --no-fuzzy-matching --backup=none --sort-output translations/app_{name}.po translations/app.pot"
|
||||
cmd = f"msgmerge --update --no-fuzzy-matching --backup=none --sort-output {TRANSLATIONS_DIR}/app_{name}.po {POT_FILE}"
|
||||
ret = os.system(cmd)
|
||||
assert ret == 0
|
||||
else:
|
||||
cmd = f"msginit -l {name} --no-translator --input translations/app.pot --output-file translations/app_{name}.po"
|
||||
cmd = f"msginit -l {name} --no-translator --input {POT_FILE} --output-file {TRANSLATIONS_DIR}/app_{name}.po"
|
||||
ret = os.system(cmd)
|
||||
assert ret == 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user