AGNOS setup: multi-lang support (#25680)

* multilang

* update translations

* Specifies dependency

* load lang from json file

* update translations

* fix white border

* remove stretch

* update translations

* fix tr

* no default language

* update translations

* rm main_en.qm

* cleanup

* cleanup

* add language files

* remove type=unfinish

* build languages before assets

* depends lrelease
pull/29656/head
Dean Lee 2 years ago committed by GitHub
parent b6b255c103
commit 0767a6dee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      selfdrive/ui/qt/setup/setup.cc
  2. 3
      selfdrive/ui/qt/setup/setup.h
  3. 2
      selfdrive/ui/qt/widgets/scrollview.cc
  4. 4
      selfdrive/ui/translations/main_de.ts
  5. 4
      selfdrive/ui/translations/main_fr.ts
  6. 4
      selfdrive/ui/translations/main_ja.ts
  7. 4
      selfdrive/ui/translations/main_ko.ts
  8. 4
      selfdrive/ui/translations/main_pt-BR.ts
  9. 4
      selfdrive/ui/translations/main_th.ts
  10. 4
      selfdrive/ui/translations/main_tr.ts
  11. 4
      selfdrive/ui/translations/main_zh-CHS.ts
  12. 4
      selfdrive/ui/translations/main_zh-CHT.ts

@ -3,6 +3,7 @@
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <string>
#include <QApplication>
#include <QLabel>
@ -10,13 +11,12 @@
#include <curl/curl.h>
#include <string>
#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<QString, QString> 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;

@ -3,6 +3,7 @@
#include <QLabel>
#include <QStackedWidget>
#include <QString>
#include <QTranslator>
#include <QWidget>
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 = "");

@ -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 {

@ -751,6 +751,10 @@ This may take up to a minute.</source>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a language</source>
<translation>Sprache wählen</translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -753,6 +753,10 @@ Cela peut prendre jusqu&apos;à une minute.</translation>
<source>Start over</source>
<translation>Recommencer</translation>
</message>
<message>
<source>Select a language</source>
<translation>Choisir une langue</translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -747,6 +747,10 @@ This may take up to a minute.</source>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a language</source>
<translation></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -749,6 +749,10 @@ This may take up to a minute.</source>
<source>No custom software found at this URL.</source>
<translation> URL에서 .</translation>
</message>
<message>
<source>Select a language</source>
<translation> </translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -753,6 +753,10 @@ Isso pode levar até um minuto.</translation>
<source>Something went wrong. Reboot the device.</source>
<translation>Algo deu errado. Reinicie o dispositivo.</translation>
</message>
<message>
<source>Select a language</source>
<translation>Selecione o Idioma</translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -749,6 +749,10 @@ This may take up to a minute.</source>
<source>No custom software found at this URL.</source>
<translation> URL </translation>
</message>
<message>
<source>Select a language</source>
<translation></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -747,6 +747,10 @@ This may take up to a minute.</source>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a language</source>
<translation>Dil seçin</translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -749,6 +749,10 @@ This may take up to a minute.</source>
<source>Something went wrong. Reboot the device.</source>
<translation></translation>
</message>
<message>
<source>Select a language</source>
<translation></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -749,6 +749,10 @@ This may take up to a minute.</source>
<source>Something went wrong. Reboot the device.</source>
<translation></translation>
</message>
<message>
<source>Select a language</source>
<translation></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

Loading…
Cancel
Save