diff --git a/selfdrive/ui/qt/setup/setup.cc b/selfdrive/ui/qt/setup/setup.cc index cdb49f1dfc..269874f115 100644 --- a/selfdrive/ui/qt/setup/setup.cc +++ b/selfdrive/ui/qt/setup/setup.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -10,13 +11,12 @@ #include -#include - #include "common/util.h" #include "system/hardware/hw.h" #include "selfdrive/ui/qt/api.h" #include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/ui/qt/offroad/networking.h" +#include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/widgets/input.h" const std::string USER_AGENT = "AGNOSSetup-"; @@ -308,6 +308,10 @@ void Setup::nextPage() { } Setup::Setup(QWidget *parent) : QStackedWidget(parent) { + if (std::getenv("MULTILANG")) { + selectLanguage(); + } + std::stringstream buffer; buffer << std::ifstream("/sys/class/hwmon/hwmon1/in1_input").rdbuf(); float voltage = (float)std::atoi(buffer.str().c_str()) / 1000.; @@ -370,6 +374,18 @@ Setup::Setup(QWidget *parent) : QStackedWidget(parent) { )"); } +void Setup::selectLanguage() { + QMap langs = getSupportedLanguages(); + QString selection = MultiOptionDialog::getSelection(tr("Select a language"), langs.keys(), "", this); + if (!selection.isEmpty()) { + QString selectedLang = langs[selection]; + Params().put("LanguageSetting", selectedLang.toStdString()); + if (translator.load(":/" + selectedLang)) { + qApp->installTranslator(&translator); + } + } +} + int main(int argc, char *argv[]) { QApplication a(argc, argv); Setup setup; diff --git a/selfdrive/ui/qt/setup/setup.h b/selfdrive/ui/qt/setup/setup.h index bf5d97070d..8c33acc380 100644 --- a/selfdrive/ui/qt/setup/setup.h +++ b/selfdrive/ui/qt/setup/setup.h @@ -3,6 +3,7 @@ #include #include #include +#include #include class Setup : public QStackedWidget { @@ -12,6 +13,7 @@ public: explicit Setup(QWidget *parent = 0); private: + void selectLanguage(); QWidget *low_voltage(); QWidget *getting_started(); QWidget *network_setup(); @@ -20,6 +22,7 @@ private: QWidget *failed_widget; QWidget *downloading_widget; + QTranslator translator; signals: void finished(const QString &url, const QString &error = ""); diff --git a/selfdrive/ui/qt/widgets/scrollview.cc b/selfdrive/ui/qt/widgets/scrollview.cc index 5536593016..978bf83a63 100644 --- a/selfdrive/ui/qt/widgets/scrollview.cc +++ b/selfdrive/ui/qt/widgets/scrollview.cc @@ -10,7 +10,7 @@ ScrollView::ScrollView(QWidget *w, QWidget *parent) : QScrollArea(parent) { setWidgetResizable(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setStyleSheet("background-color: transparent;"); + setStyleSheet("background-color: transparent; border:none"); QString style = R"( QScrollBar:vertical { diff --git a/selfdrive/ui/translations/main_de.ts b/selfdrive/ui/translations/main_de.ts index 17871ce58f..d1820fd423 100644 --- a/selfdrive/ui/translations/main_de.ts +++ b/selfdrive/ui/translations/main_de.ts @@ -751,6 +751,10 @@ This may take up to a minute. Something went wrong. Reboot the device. + + Select a language + Sprache wählen + SetupWidget diff --git a/selfdrive/ui/translations/main_fr.ts b/selfdrive/ui/translations/main_fr.ts index 14ca4df954..5908db1b2e 100644 --- a/selfdrive/ui/translations/main_fr.ts +++ b/selfdrive/ui/translations/main_fr.ts @@ -753,6 +753,10 @@ Cela peut prendre jusqu'à une minute. Start over Recommencer + + Select a language + Choisir une langue + SetupWidget diff --git a/selfdrive/ui/translations/main_ja.ts b/selfdrive/ui/translations/main_ja.ts index 799aa84a2e..16595f8ebf 100644 --- a/selfdrive/ui/translations/main_ja.ts +++ b/selfdrive/ui/translations/main_ja.ts @@ -747,6 +747,10 @@ This may take up to a minute. Something went wrong. Reboot the device. + + Select a language + 言語を選択 + SetupWidget diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts index 31190c25b9..cbd8e668ac 100644 --- a/selfdrive/ui/translations/main_ko.ts +++ b/selfdrive/ui/translations/main_ko.ts @@ -749,6 +749,10 @@ This may take up to a minute. No custom software found at this URL. 이 URL에서 커스텀 소프트웨어를 찾을 수 없습니다. + + Select a language + 언어를 선택하세요 + SetupWidget diff --git a/selfdrive/ui/translations/main_pt-BR.ts b/selfdrive/ui/translations/main_pt-BR.ts index 7aa0c7c49b..a55d31034e 100644 --- a/selfdrive/ui/translations/main_pt-BR.ts +++ b/selfdrive/ui/translations/main_pt-BR.ts @@ -753,6 +753,10 @@ Isso pode levar até um minuto. Something went wrong. Reboot the device. Algo deu errado. Reinicie o dispositivo. + + Select a language + Selecione o Idioma + SetupWidget diff --git a/selfdrive/ui/translations/main_th.ts b/selfdrive/ui/translations/main_th.ts index 9ef2d8a913..abc6210956 100644 --- a/selfdrive/ui/translations/main_th.ts +++ b/selfdrive/ui/translations/main_th.ts @@ -749,6 +749,10 @@ This may take up to a minute. No custom software found at this URL. ไม่พบซอฟต์แวร์ที่กำหนดเองที่ URL นี้ + + Select a language + เลือกภาษา + SetupWidget diff --git a/selfdrive/ui/translations/main_tr.ts b/selfdrive/ui/translations/main_tr.ts index 906884f640..febded8f59 100644 --- a/selfdrive/ui/translations/main_tr.ts +++ b/selfdrive/ui/translations/main_tr.ts @@ -747,6 +747,10 @@ This may take up to a minute. No custom software found at this URL. + + Select a language + Dil seçin + SetupWidget diff --git a/selfdrive/ui/translations/main_zh-CHS.ts b/selfdrive/ui/translations/main_zh-CHS.ts index 48eb63338b..040dae0b30 100644 --- a/selfdrive/ui/translations/main_zh-CHS.ts +++ b/selfdrive/ui/translations/main_zh-CHS.ts @@ -749,6 +749,10 @@ This may take up to a minute. Something went wrong. Reboot the device. 发生了一些错误。请重新启动您的设备。 + + Select a language + 选择语言 + SetupWidget diff --git a/selfdrive/ui/translations/main_zh-CHT.ts b/selfdrive/ui/translations/main_zh-CHT.ts index 6eacb6428c..57d9f91fec 100644 --- a/selfdrive/ui/translations/main_zh-CHT.ts +++ b/selfdrive/ui/translations/main_zh-CHT.ts @@ -749,6 +749,10 @@ This may take up to a minute. Something went wrong. Reboot the device. 發生了一些錯誤。請重新啟動您的設備。 + + Select a language + 選擇語言 + SetupWidget