summaryrefslogtreecommitdiffstats
path: root/app/Dashboard.qml
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@qt.io>2017-11-20 17:19:14 +0900
committerTasuku Suzuki <tasuku.suzuki@qt.io>2017-11-29 09:54:57 +0000
commit464e6c7f6056cec8a1d150216338d58a827307e6 (patch)
tree30b7e6321b3bbff40dfc230c3f68248b409be261 /app/Dashboard.qml
parent16ab0b453ac9a2341342b927c14ceb426e39ff05 (diff)
I18N: add basic functionality and a few translations
Added very first i18n support in the simple application. Placed language buttons at the bottom to change current language. They should be removed once current language comes from somewhere. Laying out issues should be fixed later. Change-Id: Ib5d646784820cb2753edd5a588a8826ad7d20539 Signed-off-by: Tasuku Suzuki <tasuku.suzuki@qt.io> Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Diffstat (limited to 'app/Dashboard.qml')
-rw-r--r--app/Dashboard.qml53
1 files changed, 37 insertions, 16 deletions
diff --git a/app/Dashboard.qml b/app/Dashboard.qml
index fd56521..091234d 100644
--- a/app/Dashboard.qml
+++ b/app/Dashboard.qml
@@ -18,10 +18,15 @@ 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"
@@ -109,8 +114,8 @@ ApplicationWindow {
anchors.rightMargin: -20
anchors.top: car.top
anchors.topMargin: 150
- title: 'LEFT FRONT TIRE'
- pressure: '23.1 PSI'
+ title: translator.translate(qsTr('LEFT FRONT TIRE'), translator.language)
+ pressure: translator.translate(qsTr('%1 PSI').arg(23.1), translator.language)
}
TirePressure {
@@ -118,8 +123,8 @@ ApplicationWindow {
anchors.rightMargin: -20
anchors.bottom: car.bottom
anchors.bottomMargin: 120
- title: 'LEFT REAR TIRE'
- pressure: '31.35 PSI'
+ title: translator.translate(qsTr('LEFT REAR TIRE'), translator.language)
+ pressure: translator.translate(qsTr('%1 PSI').arg(31.35), translator.language)
}
TirePressure {
@@ -128,8 +133,8 @@ ApplicationWindow {
anchors.leftMargin: -20
anchors.top: car.top
anchors.topMargin: 150
- title: 'RIGHT FRONT TIRE'
- pressure: '24.2 PSI'
+ title: translator.translate(qsTr('RIGHT FRONT TIRE'), translator.language)
+ pressure: translator.translate(qsTr('%1 PSI').arg(24.2), translator.language)
}
TirePressure {
@@ -138,8 +143,8 @@ ApplicationWindow {
anchors.leftMargin: -20
anchors.bottom : car.bottom
anchors.bottomMargin: 120
- title: 'RIGHT REAR TIRE'
- pressure: '33.0 PSI'
+ title: translator.translate(qsTr('RIGHT REAR TIRE'), translator.language)
+ pressure: translator.translate(qsTr('%1 PSI').arg(33.0), translator.language)
}
RowLayout {
@@ -160,7 +165,7 @@ ApplicationWindow {
anchors.left: parent.left
anchors.top: parent.bottom
anchors.topMargin: 10
- text: '(RPM)'
+ text: translator.translate(qsTr('(RPM)'), translator.language)
font.pixelSize: 26
}
}
@@ -190,7 +195,7 @@ ApplicationWindow {
Layout.fillHeight: true
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignRight
- text: 'LEVEL:'
+ text: translator.translate(qsTr('LEVEL:'), translator.language)
font.pixelSize: 24
}
Label {
@@ -199,7 +204,7 @@ ApplicationWindow {
Layout.fillHeight: true
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignLeft
- text: '9 GALLONS'
+ text: translator.translate(qsTr('%1 GALLONS').arg(9), translator.language)
font.pixelSize: 24
color: '#66FF99'
}
@@ -209,7 +214,7 @@ ApplicationWindow {
Layout.fillHeight: true
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignRight
- text: 'RANGE:'
+ text: translator.translate(qsTr('RANGE:'), translator.language)
font.pixelSize: 24
}
Label {
@@ -218,7 +223,7 @@ ApplicationWindow {
Layout.fillHeight: true
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignLeft
- text: '229 MI'
+ text: translator.translate(qsTr('%1 MI').arg(9), translator.language)
font.pixelSize: 24
color: '#66FF99'
}
@@ -228,7 +233,7 @@ ApplicationWindow {
Layout.fillHeight: true
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignRight
- text: 'AVG:'
+ text: translator.translate(qsTr('AVG:'), translator.language)
font.pixelSize: 24
}
Label {
@@ -237,7 +242,7 @@ ApplicationWindow {
Layout.fillHeight: true
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignLeft
- text: '25.5 MPG'
+ text: translator.translate(qsTr('%1 MPG').arg(25.5), translator.language)
font.pixelSize: 24
color: '#66FF99'
}
@@ -248,9 +253,25 @@ ApplicationWindow {
anchors.left: parent.left
anchors.top: parent.bottom
anchors.topMargin: 10
- text: 'FUEL'
+ text: translator.translate(qsTr('FUEL'), translator.language)
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
+ }
+ }
+ }
}