rev
pull/36410/head
Shane Smiskol 5 days ago
parent 1c047cd3e3
commit f64a5bd1bb
  1. 17
      selfdrive/ui/layouts/settings/device.py
  2. 2
      selfdrive/ui/translations/app_de.po
  3. 24
      selfdrive/ui/translations/languages.json
  4. 6
      selfdrive/ui/update_translations_raylib.py
  5. 8
      system/ui/lib/multilang.py
  6. 2
      system/ui/widgets/option_dialog.py

@ -12,6 +12,7 @@ from openpilot.selfdrive.ui.layouts.onboarding import TrainingGuide
from openpilot.selfdrive.ui.widgets.pairing_dialog import PairingDialog
from openpilot.system.hardware import TICI
from openpilot.system.ui.lib.application import gui_app
from openpilot.system.ui.lib.multilang import LANGUAGES_FILE, tr
from openpilot.system.ui.widgets import Widget, DialogResult
from openpilot.system.ui.widgets.confirm_dialog import ConfirmDialog, alert_dialog
from openpilot.system.ui.widgets.html_render import HtmlModal
@ -21,10 +22,10 @@ from openpilot.system.ui.widgets.scroller import Scroller
# Description constants
DESCRIPTIONS = {
'pair_device': "Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer.",
'driver_camera': "Preview the driver facing camera to ensure that driver monitoring has good visibility. (vehicle must be off)",
'reset_calibration': "openpilot requires the device to be mounted within 4° left or right and within 5° up or 9° down.",
'review_guide': "Review the rules, features, and limitations of openpilot",
'pair_device': tr("Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer."),
'driver_camera': tr("Preview the driver facing camera to ensure that driver monitoring has good visibility. (vehicle must be off)"),
'reset_calibration': tr("openpilot requires the device to be mounted within 4° left or right and within 5° up or 9° down."),
'review_guide': tr("Review the rules, features, and limitations of openpilot"),
}
@ -84,14 +85,14 @@ class DeviceLayout(Widget):
def handle_language_selection(result: int):
if result == 1 and self._select_language_dialog:
selected_language = self._select_language_dialog.selection
print("Selected language:", selected_language)
self._params.put("LanguageSetting", selected_language)
print("Selected language:", languages[selected_language])
self._params.put("LanguageSetting", languages[selected_language])
self._select_language_dialog = None
try:
languages_file = os.path.join(BASEDIR, "selfdrive/ui/translations/languages.json")
with open(languages_file, encoding='utf-8') as f:
# TODO: get from multilang file
with open(LANGUAGES_FILE, encoding='utf-8') as f:
languages = json.load(f)
self._select_language_dialog = MultiOptionDialog("Select a language", languages)

@ -20,7 +20,7 @@ msgstr ""
#: /home/batman/openpilot/selfdrive/ui/widgets/prime.py:33
#, python-format
msgid "Upgrade Now"
msgstr ""
msgstr "Opgrader nu"
#: /home/batman/openpilot/selfdrive/ui/widgets/prime.py:38
#, python-format

@ -1,14 +1,14 @@
{
"English": "main_en",
"Deutsch": "main_de",
"Français": "main_fr",
"Português": "main_pt-BR",
"Español": "main_es",
"Türkçe": "main_tr",
"العربية": "main_ar",
"ไทย": "main_th",
"中文(繁體)": "main_zh-CHT",
"中文(简体)": "main_zh-CHS",
"한국어": "main_ko",
"日本語": "main_ja"
"English": "en",
"Deutsch": "de",
"Français": "fr",
"Português": "pt-BR",
"Español": "es",
"Türkçe": "tr",
"العربية": "ar",
"ไทย": "th",
"中文(繁體)": "zh-CHT",
"中文(简体)": "zh-CHS",
"한국어": "ko",
"日本語": "ja"
}

@ -3,11 +3,7 @@ import argparse
import json
import os
from openpilot.common.basedir import BASEDIR
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")
from openpilot.system.ui.lib.multilang import UI_DIR, TRANSLATIONS_DIR, LANGUAGES_FILE
def update_translations():

@ -5,9 +5,14 @@ from openpilot.common.params import Params
from openpilot.common.basedir import BASEDIR
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")
class Multilang:
def __init__(self):
self._language: str = "main_en"
self._language: str = "en"
self._translations: dict[str, dict[str, str]] = {}
self._load_languages()
@ -27,6 +32,7 @@ class Multilang:
pass
def _get_translated_text(self, text: str) -> str:
# print("Translating:", text, "to", self._language, self._translations.keys())
if self._language not in self._translations:
return text
return self._translations[self._language].get(text, text)

@ -27,7 +27,7 @@ class MultiOptionDialog(Widget):
# Create scroller with option buttons
self.option_buttons = [Button(option, click_callback=lambda opt=option: self._on_option_clicked(opt),
text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, button_style=ButtonStyle.NORMAL,
text_padding=50, elide_right=True) for option in options]
text_padding=50) for option in options]
self.scroller = Scroller(self.option_buttons, spacing=LIST_ITEM_SPACING)
self.cancel_button = Button("Cancel", click_callback=lambda: self._set_result(DialogResult.CANCEL))

Loading…
Cancel
Save