mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 00:05:59 +08:00
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
This commit is contained in:
@@ -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'à 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>
|
||||
|
||||
Reference in New Issue
Block a user