diff options
author | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2017-12-20 00:20:38 +0900 |
---|---|---|
committer | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2017-12-20 00:20:38 +0900 |
commit | 673e806f312b1fda4bee4af30e59699bb1f3547c (patch) | |
tree | 9754ee55da016c6b73080ec858e0fec200aa1a97 /app | |
parent | 8651e32f3897c10cb2a71464fc8122b288091472 (diff) |
Revert "I18N: add basic functionality and a few translations"
NOTE: I18N features isn't supported in EEL/CES2018 yet.
This reverts commit e26dac76bc82ba7888726cc0b2eb5103b50ef17e.
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/Dashboard.qml | 53 | ||||
-rw-r--r-- | app/app.pro | 10 | ||||
-rw-r--r-- | app/main.cpp | 13 | ||||
-rw-r--r-- | app/translations.pri | 16 | ||||
-rw-r--r-- | app/translations/dashboard_fr_FR.ts | 88 | ||||
-rw-r--r-- | app/translations/dashboard_ja_JP.ts | 88 | ||||
-rw-r--r-- | app/translations/dashboard_zh_CN.ts | 88 | ||||
-rw-r--r-- | app/translator.cpp | 52 | ||||
-rw-r--r-- | app/translator.h | 32 |
9 files changed, 21 insertions, 419 deletions
diff --git a/app/Dashboard.qml b/app/Dashboard.qml index 091234d..fd56521 100644 --- a/app/Dashboard.qml +++ b/app/Dashboard.qml @@ -18,15 +18,10 @@ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtWebSockets 1.0 -import Translator 1.0 ApplicationWindow { id: root - Translator { - id: translator - } - WebSocket { property string api_str: "api/canivi" property string verb_str: "subscribe" @@ -114,8 +109,8 @@ ApplicationWindow { anchors.rightMargin: -20 anchors.top: car.top anchors.topMargin: 150 - title: translator.translate(qsTr('LEFT FRONT TIRE'), translator.language) - pressure: translator.translate(qsTr('%1 PSI').arg(23.1), translator.language) + title: 'LEFT FRONT TIRE' + pressure: '23.1 PSI' } TirePressure { @@ -123,8 +118,8 @@ ApplicationWindow { anchors.rightMargin: -20 anchors.bottom: car.bottom anchors.bottomMargin: 120 - title: translator.translate(qsTr('LEFT REAR TIRE'), translator.language) - pressure: translator.translate(qsTr('%1 PSI').arg(31.35), translator.language) + title: 'LEFT REAR TIRE' + pressure: '31.35 PSI' } TirePressure { @@ -133,8 +128,8 @@ ApplicationWindow { anchors.leftMargin: -20 anchors.top: car.top anchors.topMargin: 150 - title: translator.translate(qsTr('RIGHT FRONT TIRE'), translator.language) - pressure: translator.translate(qsTr('%1 PSI').arg(24.2), translator.language) + title: 'RIGHT FRONT TIRE' + pressure: '24.2 PSI' } TirePressure { @@ -143,8 +138,8 @@ ApplicationWindow { anchors.leftMargin: -20 anchors.bottom : car.bottom anchors.bottomMargin: 120 - title: translator.translate(qsTr('RIGHT REAR TIRE'), translator.language) - pressure: translator.translate(qsTr('%1 PSI').arg(33.0), translator.language) + title: 'RIGHT REAR TIRE' + pressure: '33.0 PSI' } RowLayout { @@ -165,7 +160,7 @@ ApplicationWindow { anchors.left: parent.left anchors.top: parent.bottom anchors.topMargin: 10 - text: translator.translate(qsTr('(RPM)'), translator.language) + text: '(RPM)' font.pixelSize: 26 } } @@ -195,7 +190,7 @@ ApplicationWindow { Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Label.AlignRight - text: translator.translate(qsTr('LEVEL:'), translator.language) + text: 'LEVEL:' font.pixelSize: 24 } Label { @@ -204,7 +199,7 @@ ApplicationWindow { Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Label.AlignLeft - text: translator.translate(qsTr('%1 GALLONS').arg(9), translator.language) + text: '9 GALLONS' font.pixelSize: 24 color: '#66FF99' } @@ -214,7 +209,7 @@ ApplicationWindow { Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Label.AlignRight - text: translator.translate(qsTr('RANGE:'), translator.language) + text: 'RANGE:' font.pixelSize: 24 } Label { @@ -223,7 +218,7 @@ ApplicationWindow { Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Label.AlignLeft - text: translator.translate(qsTr('%1 MI').arg(9), translator.language) + text: '229 MI' font.pixelSize: 24 color: '#66FF99' } @@ -233,7 +228,7 @@ ApplicationWindow { Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Label.AlignRight - text: translator.translate(qsTr('AVG:'), translator.language) + text: 'AVG:' font.pixelSize: 24 } Label { @@ -242,7 +237,7 @@ ApplicationWindow { Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Label.AlignLeft - text: translator.translate(qsTr('%1 MPG').arg(25.5), translator.language) + text: '25.5 MPG' font.pixelSize: 24 color: '#66FF99' } @@ -253,25 +248,9 @@ ApplicationWindow { anchors.left: parent.left anchors.top: parent.bottom anchors.topMargin: 10 - text: translator.translate(qsTr('FUEL'), translator.language) + text: 'FUEL' font.pixelSize: 26 } } } - - RowLayout { -// visible: false - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.right: parent.right - Repeater { - model: ['C', 'fr_FR', 'ja_JP', 'zh_CN'] - - Button { - text: model.modelData - onClicked: translator.language = model.modelData - Layout.fillWidth: true - } - } - } } diff --git a/app/app.pro b/app/app.pro index 1aa4da0..9599de1 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,12 +1,7 @@ TARGET = dashboard QT = quickcontrols2 - -HEADERS += \ - translator.h - -SOURCES = main.cpp \ - translator.cpp +SOURCES = main.cpp CONFIG += link_pkgconfig PKGCONFIG += libhomescreen qlibwindowmanager @@ -16,6 +11,3 @@ RESOURCES += \ images/images.qrc include(app.pri) - -LANGUAGES = ja_JP fr_FR zh_CN -include(translations.pri) diff --git a/app/main.cpp b/app/main.cpp index d7f15b5..9649b82 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -14,17 +14,14 @@ * limitations under the License. */ +#include <QUrlQuery> +#include <QQmlContext> #include <QtCore/QDebug> -#include <QtCore/QCommandLineParser> -#include <QtCore/QUrlQuery> +#include <QCommandLineParser> #include <QtGui/QGuiApplication> -#include <QtQml/QQmlContext> #include <QtQml/QQmlApplicationEngine> -#include <QtQuick/QQuickWindow> #include <QtQuickControls2/QQuickStyle> - -#include "translator.h" - +#include <QQuickWindow> #include <libhomescreen.hpp> #include <qlibwindowmanager.h> @@ -48,8 +45,6 @@ int main(int argc, char *argv[]) parser.process(app); QStringList positionalArguments = parser.positionalArguments(); - qmlRegisterType<Translator>("Translator", 1, 0, "Translator"); - QQmlApplicationEngine engine; if (positionalArguments.length() == 2) { int port = positionalArguments.takeFirst().toInt(); diff --git a/app/translations.pri b/app/translations.pri deleted file mode 100644 index d5616ef..0000000 --- a/app/translations.pri +++ /dev/null @@ -1,16 +0,0 @@ -defineReplace(prependAll) { - for(a,$$1):result += $$2$${a}$$3 - return($$result) -} - -LRELEASE = lrelease -TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/translations/$${TARGET}_,.ts) - -qm.depends = $${TRANSLATIONS} -qm.input = TRANSLATIONS -qm.output = $$OUT_PWD/../package/root/translations/${QMAKE_FILE_BASE}.qm -qm.commands = $$LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} -qm.name = LRELEASE ${QMAKE_FILE_IN} -qm.CONFIG += no_link -QMAKE_EXTRA_COMPILERS += qm -PRE_TARGETDEPS += compiler_qm_make_all diff --git a/app/translations/dashboard_fr_FR.ts b/app/translations/dashboard_fr_FR.ts deleted file mode 100644 index 2b7cf6e..0000000 --- a/app/translations/dashboard_fr_FR.ts +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="fr_FR"> -<context> - <name>Dashboard</name> - <message> - <location filename="../Dashboard.qml" line="120"/> - <source>LEFT FRONT TIRE</source> - <translation>Pneu Avant Gauche</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="121"/> - <location filename="../Dashboard.qml" line="130"/> - <location filename="../Dashboard.qml" line="140"/> - <location filename="../Dashboard.qml" line="150"/> - <source>%1 PSI</source> - <translation>Pression %1</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="129"/> - <source>LEFT REAR TIRE</source> - <translation>Pneu Arrière Gauche</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="139"/> - <source>RIGHT FRONT TIRE</source> - <translation>Pneu Avant Droit</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="149"/> - <source>RIGHT REAR TIRE</source> - <translation>Pneu Arrière Droit</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="171"/> - <source>(RPM)</source> - <translation>Tr/mn</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="201"/> - <source>LEVEL:</source> - <translation>Niveau:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="210"/> - <source>%1 GALLONS</source> - <translation>%1 Litres</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="220"/> - <source>RANGE:</source> - <translation>Autonomie:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="229"/> - <source>%1 MI</source> - <translation>%1 Km</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="239"/> - <source>AVG:</source> - <translation>Moyenne:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="248"/> - <source>%1 MPG</source> - <translation>%1 l/100km</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="259"/> - <source>FUEL</source> - <translation>Carburant</translation> - </message> -</context> -<context> - <name>main</name> - <message> - <location filename="../main.cpp" line="50"/> - <source>port for binding</source> - <translation>Port du Binder</translation> - </message> - <message> - <location filename="../main.cpp" line="51"/> - <source>secret for binding</source> - <translation>Secret Binder</translation> - </message> -</context> -</TS> diff --git a/app/translations/dashboard_ja_JP.ts b/app/translations/dashboard_ja_JP.ts deleted file mode 100644 index 06b25dc..0000000 --- a/app/translations/dashboard_ja_JP.ts +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="ja_JP"> -<context> - <name>Dashboard</name> - <message> - <location filename="../Dashboard.qml" line="115"/> - <source>LEFT FRONT TIRE</source> - <translation>左前輪</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="116"/> - <location filename="../Dashboard.qml" line="125"/> - <location filename="../Dashboard.qml" line="135"/> - <location filename="../Dashboard.qml" line="145"/> - <source>%1 PSI</source> - <translation>空気圧 %1</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="124"/> - <source>LEFT REAR TIRE</source> - <translation>左後輪</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="134"/> - <source>RIGHT FRONT TIRE</source> - <translation>右前輪</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="144"/> - <source>RIGHT REAR TIRE</source> - <translation>右後輪</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="166"/> - <source>(RPM)</source> - <translation>(RPM)</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="196"/> - <source>LEVEL:</source> - <translation>レベル:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="205"/> - <source>%1 GALLONS</source> - <translation>%1 ガロン</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="215"/> - <source>RANGE:</source> - <translation>レンジ:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="224"/> - <source>%1 MI</source> - <translation>%1 MI</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="234"/> - <source>AVG:</source> - <translation>平均:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="243"/> - <source>%1 MPG</source> - <translation>%1 MPG</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="254"/> - <source>FUEL</source> - <translation>燃料</translation> - </message> -</context> -<context> - <name>main</name> - <message> - <location filename="../main.cpp" line="49"/> - <source>port for binding</source> - <translation type="unfinished"></translation> - </message> - <message> - <location filename="../main.cpp" line="50"/> - <source>secret for binding</source> - <translation type="unfinished"></translation> - </message> -</context> -</TS> diff --git a/app/translations/dashboard_zh_CN.ts b/app/translations/dashboard_zh_CN.ts deleted file mode 100644 index ece07f9..0000000 --- a/app/translations/dashboard_zh_CN.ts +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="fr_FR"> -<context> - <name>Dashboard</name> - <message> - <location filename="../Dashboard.qml" line="120"/> - <source>LEFT FRONT TIRE</source> - <translation>左前车胎</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="121"/> - <location filename="../Dashboard.qml" line="130"/> - <location filename="../Dashboard.qml" line="140"/> - <location filename="../Dashboard.qml" line="150"/> - <source>%1 PSI</source> - <translation>%1 磅每平方英寸(PSI)</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="129"/> - <source>LEFT REAR TIRE</source> - <translation>左后车胎</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="139"/> - <source>RIGHT FRONT TIRE</source> - <translation>右前车胎</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="149"/> - <source>RIGHT REAR TIRE</source> - <translation>右后车胎</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="171"/> - <source>(RPM)</source> - <translation>引擎转速</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="201"/> - <source>LEVEL:</source> - <translation>剩余油量:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="210"/> - <source>%1 GALLONS</source> - <translation>%1 加仑</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="220"/> - <source>RANGE:</source> - <translation>续航里程:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="229"/> - <source>%1 MI</source> - <translation>%1 英里</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="239"/> - <source>AVG:</source> - <translation type="unfinished">平均油耗:</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="248"/> - <source>%1 MPG</source> - <translation type="unfinished">%1 英里每加仑(MPG)</translation> - </message> - <message> - <location filename="../Dashboard.qml" line="259"/> - <source>FUEL</source> - <translation>燃油</translation> - </message> -</context> -<context> - <name>main</name> - <message> - <location filename="../main.cpp" line="50"/> - <source>port for binding</source> - <translation>Binder端口</translation> - </message> - <message> - <location filename="../main.cpp" line="51"/> - <source>secret for binding</source> - <translation>Binder令牌</translation> - </message> -</context> -</TS> diff --git a/app/translator.cpp b/app/translator.cpp deleted file mode 100644 index 9b67f13..0000000 --- a/app/translator.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "translator.h" - -#include <QtCore/QCoreApplication> -#include <QtCore/QLocale> -#include <QtCore/QTranslator> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -Translator::Translator(QObject *parent) - : QObject(parent) - , m_language(QStringLiteral("C")) - , m_translator(nullptr) -{ -} - -QString Translator::translate(const QString &string, const QString &language) const -{ - Q_UNUSED(language) - return string; -} - -QString Translator::language() const -{ - return m_language; -} - -void Translator::setLanguage(const QString &language) -{ - if (m_language == language) return; - m_language = language; - setTranslator(language); - emit languageChanged(language); -} - -void Translator::setTranslator(const QString &language) -{ - if (m_translator) { - QCoreApplication::removeTranslator(m_translator); - } else { - m_translator = new QTranslator(this); - } - QLocale locale(language); - QString fileName = QCoreApplication::instance()->applicationName().toLower(); - qDebug() << "####" << QDir::currentPath() << QCoreApplication::applicationDirPath(); - if (m_translator->load(locale, fileName, QStringLiteral("_"), QStringLiteral("%1/../translations").arg(QCoreApplication::applicationDirPath()))) { - QCoreApplication::installTranslator(m_translator); - } else { - delete m_translator; - m_translator = nullptr; - } -} - diff --git a/app/translator.h b/app/translator.h deleted file mode 100644 index 82c5872..0000000 --- a/app/translator.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TRANSLATOR_H -#define TRANSLATOR_H - -#include <QtCore/QObject> - -class QTranslator; - -class Translator : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged) -public: - explicit Translator(QObject *parent = nullptr); - - QString language() const; - - Q_INVOKABLE QString translate(const QString &string, const QString &language) const; -public slots: - void setLanguage(const QString &language); - -signals: - void languageChanged(const QString &language); - -private slots: - void setTranslator(const QString &language); - -private: - QString m_language; - QTranslator *m_translator; -}; - -#endif // TRANSLATOR_H |