From 673e806f312b1fda4bee4af30e59699bb1f3547c Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Wed, 20 Dec 2017 00:20:38 +0900 Subject: 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 --- app/Dashboard.qml | 53 +++++++--------------- app/app.pro | 10 +---- app/main.cpp | 13 ++---- app/translations.pri | 16 ------- app/translations/dashboard_fr_FR.ts | 88 ------------------------------------- app/translations/dashboard_ja_JP.ts | 88 ------------------------------------- app/translations/dashboard_zh_CN.ts | 88 ------------------------------------- app/translator.cpp | 52 ---------------------- app/translator.h | 32 -------------- 9 files changed, 21 insertions(+), 419 deletions(-) delete mode 100644 app/translations.pri delete mode 100644 app/translations/dashboard_fr_FR.ts delete mode 100644 app/translations/dashboard_ja_JP.ts delete mode 100644 app/translations/dashboard_zh_CN.ts delete mode 100644 app/translator.cpp delete mode 100644 app/translator.h (limited to 'app') 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 +#include #include -#include -#include +#include #include -#include #include -#include #include - -#include "translator.h" - +#include #include #include @@ -48,8 +45,6 @@ int main(int argc, char *argv[]) parser.process(app); QStringList positionalArguments = parser.positionalArguments(); - qmlRegisterType("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 @@ - - - - - Dashboard - - - LEFT FRONT TIRE - Pneu Avant Gauche - - - - - - - %1 PSI - Pression %1 - - - - LEFT REAR TIRE - Pneu Arrière Gauche - - - - RIGHT FRONT TIRE - Pneu Avant Droit - - - - RIGHT REAR TIRE - Pneu Arrière Droit - - - - (RPM) - Tr/mn - - - - LEVEL: - Niveau: - - - - %1 GALLONS - %1 Litres - - - - RANGE: - Autonomie: - - - - %1 MI - %1 Km - - - - AVG: - Moyenne: - - - - %1 MPG - %1 l/100km - - - - FUEL - Carburant - - - - main - - - port for binding - Port du Binder - - - - secret for binding - Secret Binder - - - 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 @@ - - - - - Dashboard - - - LEFT FRONT TIRE - 左前輪 - - - - - - - %1 PSI - 空気圧 %1 - - - - LEFT REAR TIRE - 左後輪 - - - - RIGHT FRONT TIRE - 右前輪 - - - - RIGHT REAR TIRE - 右後輪 - - - - (RPM) - (RPM) - - - - LEVEL: - レベル: - - - - %1 GALLONS - %1 ガロン - - - - RANGE: - レンジ: - - - - %1 MI - %1 MI - - - - AVG: - 平均: - - - - %1 MPG - %1 MPG - - - - FUEL - 燃料 - - - - main - - - port for binding - - - - - secret for binding - - - - 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 @@ - - - - - Dashboard - - - LEFT FRONT TIRE - 左前车胎 - - - - - - - %1 PSI - %1 磅每平方英寸(PSI) - - - - LEFT REAR TIRE - 左后车胎 - - - - RIGHT FRONT TIRE - 右前车胎 - - - - RIGHT REAR TIRE - 右后车胎 - - - - (RPM) - 引擎转速 - - - - LEVEL: - 剩余油量: - - - - %1 GALLONS - %1 加仑 - - - - RANGE: - 续航里程: - - - - %1 MI - %1 英里 - - - - AVG: - 平均油耗: - - - - %1 MPG - %1 英里每加仑(MPG) - - - - FUEL - 燃油 - - - - main - - - port for binding - Binder端口 - - - - secret for binding - Binder令牌 - - - 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 -#include -#include -#include -#include - -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 - -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 -- cgit 1.2.3-korg