Browse Source

Attempt at translation support

translation
Colin Reeder 3 years ago
parent
commit
465ffa1dbf
5 changed files with 88 additions and 11 deletions
  1. +10
    -10
      qml/Main.qml
  2. +10
    -0
      src/main.rs
  3. +8
    -1
      src/qrc.rs
  4. BIN
      ts/qm/radiate_eo.qm
  5. +60
    -0
      ts/radiate_eo.ts

+ 10
- 10
qml/Main.qml View File

@@ -70,28 +70,28 @@ ApplicationWindow {
Page {
header: Loader {
sourceComponent: headerBar
property var title: "Connect to Bridge"
property var title: qsTr("Connect to Bridge")
}

ColumnLayout {
Label {
id: statusText
text: "Searching for Hue bridges..."
text: qsTr("Searching for Hue bridges...")
}
}

PairingManager {
id: connector
onDiscovered_bridges: {
statusText.text = "Found %1 bridge(s). Press the button to pair.".arg(count)
statusText.text = qsTr("Found %Ln bridge(s). Press the button to pair.", "", count)
}
onErrored: {
statusText.text = "Error: %1".arg(err)
statusText.text = qsTr("Error: %1").arg(err)
}
onAuthenticated: {
settings.bridgeHost = address;
settings.bridgeUsername = username;
statusText.text = "Connected.";
statusText.text = qsTr("Connected.");
stackView.replace(homePage)
}
}
@@ -202,8 +202,8 @@ ApplicationWindow {
currentIndex: tabView.currentIndex
Layout.fillWidth: true

TabButton { text: "Lights" }
TabButton { text: "Groups" }
TabButton { text: qsTr("Lights") }
TabButton { text: qsTr("Groups") }
}
}

@@ -329,7 +329,7 @@ ApplicationWindow {
width: parent.width
Item { Layout.preferredWidth: 8 }
Label {
text: "Brightness"
text: qsTr("Brightness")
verticalAlignment: Text.AlignVCenter
}
Item { Layout.fillWidth: true }
@@ -357,7 +357,7 @@ ApplicationWindow {
Layout.preferredWidth: 8
}
Label {
text: "Hue"
text: qsTr("Hue")
verticalAlignment: Text.AlignVCenter
}
Item { Layout.fillWidth: true }
@@ -385,7 +385,7 @@ ApplicationWindow {
Layout.preferredWidth: 8
}
Label {
text: "Saturation"
text: qsTr("Saturation")
verticalAlignment: Text.AlignVCenter
}
Item { Layout.fillWidth: true }


+ 10
- 0
src/main.rs View File

@@ -24,6 +24,7 @@ fn main() {
}}
cpp!{[]{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QCoreApplication::setOrganizationName("radiate.vpzom");
QCoreApplication::setOrganizationDomain("vpzom.click");
QCoreApplication::setApplicationName("radiate");
@@ -37,6 +38,15 @@ fn main() {
qml_register_type::<PairingManager>(plugin_name, 0, 0, cstr!("PairingManager"));
qml_register_type::<BridgeConnectionConnector>(plugin_name, 0, 0, cstr!("BridgeConnectionConnector"));
let mut engine = QmlEngine::new();
unsafe {
cpp!{[]{
QTranslator translator;
qDebug() << "lang: " << QLocale::languageToString(QLocale("eo").language());
bool loaded = translator.load("radiate", ":/translations");
qDebug() << "LOADED?" << loaded;
QCoreApplication::installTranslator(&translator);
}}
}
engine.load_file("qrc:/qml/Main.qml".into());
engine.exec();
Ok(())


+ 8
- 1
src/qrc.rs View File

@@ -1,9 +1,16 @@
qrc!(qml_resources,
"/" {
"qml/Main.qml"
},
}
);

qrc!(translations,
"translations" {
"ts/qm/radiate_eo.qm" as "radiate_eo.qm"
}
);

pub fn load() {
qml_resources();
translations();
}

BIN
ts/qm/radiate_eo.qm View File


+ 60
- 0
ts/radiate_eo.ts View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="eo">
<context>
<name>Main</name>
<message>
<location filename="../qml/Main.qml" line="73"/>
<source>Connect to Bridge</source>
<translation>Konekti al Ponton</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="79"/>
<source>Searching for Hue bridges...</source>
<translation>Serĉas Hue-pontojn...</translation>
</message>
<message numerus="yes">
<location filename="../qml/Main.qml" line="86"/>
<source>Found %Ln bridge(s). Press the button to pair.</source>
<translation>
<numerusform>Trovis %Ln ponton. Premu la butonon al parigi.</numerusform>
<numerusform>Trovis %Ln pontojn. Premu la butonon al parigi.</numerusform>
</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="89"/>
<source>Error: %1</source>
<translation>Eraro: %1</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="94"/>
<source>Connected.</source>
<translation>Konektis.</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="205"/>
<source>Lights</source>
<translation>Lumoj</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="206"/>
<source>Groups</source>
<translation>Grupoj</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="332"/>
<source>Brightness</source>
<translation>Brilo</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="360"/>
<source>Hue</source>
<translation>Nuanco</translation>
</message>
<message>
<location filename="../qml/Main.qml" line="388"/>
<source>Saturation</source>
<translation>Satureco</translation>
</message>
</context>
</TS>

Loading…
Cancel
Save