From bdc6eaee726a91301153c5e67b55f9324cacae85 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Sat, 30 Dec 2017 16:04:18 +0100 Subject: Languages changing depending on identity logged in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8eca6e0f7ddd042c9434132537eeccd74b982718 Signed-off-by: Romain Forlot update translation on language changed Change-Id: I12130b4a1c5c6dad9658972d32b4b9e362a8d1cc Signed-off-by: Loïc Collignon --- app/HVAC.qml | 3 ++- app/api/Binding.qml | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/HVAC.qml b/app/HVAC.qml index c375f2f..b1925dd 100644 --- a/app/HVAC.qml +++ b/app/HVAC.qml @@ -26,13 +26,14 @@ ApplicationWindow { Translator { id: translator -// language: 'ja_JP' + language: binding.language } API.Binding { id: binding url: bindingAddress onFanSpeedChanged: fanSpeedSlider.value = fanSpeed + onLanguageChanged: translator.language = language } ColumnLayout { diff --git a/app/api/Binding.qml b/app/api/Binding.qml index 93da6f4..25388df 100644 --- a/app/api/Binding.qml +++ b/app/api/Binding.qml @@ -27,6 +27,7 @@ WebSocket { property real fanSpeed: 0.0 property real leftTemperature: 21.0 property real rightTemperature: 21.0 + property string language: "en_US" property Connections c : Connections { target: root @@ -45,6 +46,11 @@ WebSocket { console.debug(JSON.stringify(json)) sendTextMessage(JSON.stringify(json)) } + onLanguageChanged: { + var json = [MessageId.call, '9999', 'hvac/set', {'Language': language}] + console.debug(JSON.stringify(json)) + sendTextMessage(JSON.stringify(json)) + } } onTextMessageReceived: { @@ -62,6 +68,10 @@ WebSocket { root.statusString = "Bad return value, binding probably not installed" break case MessageId.event: + if (json[1] == "hvac/language") + console.log("HVAC event received: ",json[2]) + root.language = json[2].data + root.statusString = "Language changed to "+language break } } -- cgit 1.2.3-korg