pull/36410/head
Shane Smiskol 2 weeks ago
parent 49bc4b596d
commit 455fd2c0d0
  1. 2
      common/params_keys.h
  2. 2
      selfdrive/ui/.gitignore
  3. 2
      selfdrive/ui/SConscript
  4. 4
      selfdrive/ui/tests/create_test_translations.sh
  5. 2
      selfdrive/ui/tests/test_runner.cc
  6. 2
      selfdrive/ui/translations/app.pot
  7. 816
      selfdrive/ui/translations/app_ar.po
  8. 1175
      selfdrive/ui/translations/app_en.po
  9. 816
      selfdrive/ui/translations/app_fr.po
  10. 810
      selfdrive/ui/translations/app_ja.po
  11. 810
      selfdrive/ui/translations/app_ko.po
  12. 816
      selfdrive/ui/translations/app_pt-BR.po
  13. 816
      selfdrive/ui/translations/app_th.po
  14. 816
      selfdrive/ui/translations/app_tr.po
  15. 816
      selfdrive/ui/translations/app_zh-CHS.po
  16. 816
      selfdrive/ui/translations/app_zh-CHT.po
  17. 2
      selfdrive/ui/translations/auto_translate.py
  18. 2
      selfdrive/ui/update_translations.py
  19. 3
      selfdrive/ui/update_translations_raylib.py
  20. 18
      system/ui/lib/multilang.py

@ -66,7 +66,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"IsTakingSnapshot", {CLEAR_ON_MANAGER_START, BOOL}},
{"IsTestedBranch", {CLEAR_ON_MANAGER_START, BOOL}},
{"JoystickDebugMode", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL}},
{"LanguageSetting", {PERSISTENT, STRING, "main_en"}},
{"LanguageSetting", {PERSISTENT, STRING, "en"}},
{"LastAthenaPingTime", {CLEAR_ON_MANAGER_START, INT}},
{"LastGPSPosition", {PERSISTENT, STRING}},
{"LastManagerExitReason", {CLEAR_ON_MANAGER_START, STRING}},

@ -1,7 +1,7 @@
moc_*
*.moc
translations/main_test_en.*
translations/test_en.*
ui
mui

@ -98,7 +98,7 @@ if GetOption('extras'):
assert f[0].get_size() < 1900*1e3, f[0].get_size()
# Compile gettext .po -> .mo alongside Qt translations
po_sources = [f"#selfdrive/ui/translations/app_{l.replace('main_', '')}.po" for l in languages.values()]
po_sources = [f"#selfdrive/ui/translations/app_{l}.po" for l in languages.values()]
mo_targets = [src.replace(".po", ".mo") for src in po_sources]
msgfmt_bin = 'msgfmt'

@ -4,8 +4,8 @@ set -e
UI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"/..
TEST_TEXT="(WRAPPED_SOURCE_TEXT)"
TEST_TS_FILE=$UI_DIR/translations/main_test_en.ts
TEST_QM_FILE=$UI_DIR/translations/main_test_en.qm
TEST_TS_FILE=$UI_DIR/translations/test_en.ts
TEST_QM_FILE=$UI_DIR/translations/test_en.qm
# translation strings
UNFINISHED="<translation type=\"unfinished\"><\/translation>"

@ -10,7 +10,7 @@ int main(int argc, char **argv) {
// unit tests for Qt
QApplication app(argc, argv);
QString language_file = "main_test_en";
QString language_file = "test_en";
// FIXME: pytest-cpp considers this print as a test case
qDebug() << "Loading language:" << language_file;

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-10-20 17:23-0700\n"
"POT-Creation-Date: 2025-10-20 18:19-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

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

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

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

File diff suppressed because it is too large Load Diff

@ -26,7 +26,7 @@ def get_language_files(languages: list[str] = None) -> dict[str, pathlib.Path]:
for filename in language_dict.values():
path = TRANSLATIONS_DIR / f"{filename}.ts"
language = path.stem.split("main_")[1]
language = path.stem
if languages is None or language in languages:
files[language] = path

@ -9,7 +9,7 @@ UI_DIR = os.path.join(BASEDIR, "selfdrive", "ui")
TRANSLATIONS_DIR = os.path.join(UI_DIR, "translations")
LANGUAGES_FILE = os.path.join(TRANSLATIONS_DIR, "languages.json")
TRANSLATIONS_INCLUDE_FILE = os.path.join(TRANSLATIONS_DIR, "alerts_generated.h")
PLURAL_ONLY = ["main_en"] # base language, only create entries for strings with plural forms
PLURAL_ONLY = ["en"] # base language, only create entries for strings with plural forms
def generate_translations_include():

@ -30,8 +30,7 @@ def update_translations():
with open(LANGUAGES_FILE) as f:
translation_files = json.load(f).values()
for file in translation_files:
name = file.replace("main_", "")
for name in translation_files:
if os.path.exists(os.path.join(TRANSLATIONS_DIR, f"app_{name}.po")):
cmd = f"msgmerge --update --backup=none --sort-output translations/app_{name}.po translations/app.pot"
ret = os.system(cmd)

@ -1,4 +1,5 @@
import os
import json
import gettext
from openpilot.common.params import Params
from openpilot.common.basedir import BASEDIR
@ -13,12 +14,10 @@ class Multilang:
def __init__(self):
self._params = Params()
self._language: str = self._params.get("LanguageSetting").strip("main_")
self._languages = {}
self._load_languages()
print(f"Multilang initialized with language: {self._language}")
# self._translations: dict[str, dict[str, str]] = {}
# self._load_languages()
def setup(self):
# global tr, trn
try:
@ -47,13 +46,10 @@ class Multilang:
# return text
# return self._translations[self._language].get(text, text)
#
# def _load_languages(self):
# self._language = Params().get("LanguageSetting")
#
# LANGUAGE_DIR = os.path.join(BASEDIR, "selfdrive", "ui", "translations")
# for file in os.listdir(LANGUAGE_DIR):
# if file.endswith(".ts"):
# pass
def _load_languages(self):
with open(LANGUAGES_FILE, encoding='utf-8') as f:
self._languages = json.load(f)
print(f"Available languages: {self._languages}")
# # l = gettext.translation('app_de', localedir=TRANSLATIONS_DIR, languages=['de'])

Loading…
Cancel
Save