Commit ee2ff95b authored by Marco Martin's avatar Marco Martin

support translations in faces

Summary: give each face its own catalog

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29706
parent d5bd5e3f
......@@ -100,16 +100,16 @@ Kirigami.FormLayout {
}
}
RowLayout {
Kirigami.FormData.label: i18n("Presets:")
Kirigami.FormData.label: i18nd("KSysGuardSensorFaces", "Presets:")
QQC2.Button {
icon.name: "document-open"
text: i18n("Load Preset...")
text: i18nd("KSysGuardSensorFaces", "Load Preset...")
onClicked: presetSheet.open()
}
NewStuff.Button {
Accessible.name: i18n("Get new presets...")
Accessible.name: i18nd("KSysGuardSensorFaces", "Get new presets...")
configFile: "systemmonitor-presets.knsrc"
text: ""
onChangedEntriesChanged: controller.availablePresetsModel.reload();
......@@ -121,7 +121,7 @@ Kirigami.FormLayout {
QQC2.Button {
id: saveButton
icon.name: "document-save"
text: i18n("Save Settings As Preset")
text: i18nd("KSysGuardSensorFaces", "Save Settings As Preset")
enabled: controller.currentPreset.length == 0
onClicked: controller.savePreset();
}
......@@ -133,11 +133,11 @@ Kirigami.FormLayout {
QQC2.TextField {
id: titleField
Kirigami.FormData.label: i18n("Title:")
Kirigami.FormData.label: i18nd("KSysGuardSensorFaces", "Title:")
}
RowLayout {
Kirigami.FormData.label: i18n("Display Style:")
Kirigami.FormData.label: i18nd("KSysGuardSensorFaces", "Display Style:")
QQC2.ComboBox {
id: faceCombo
model: controller.availableFacesModel
......@@ -157,7 +157,7 @@ Kirigami.FormLayout {
}
NewStuff.Button {
text: i18n("Get New Display Styles...")
text: i18nd("KSysGuardSensorFaces", "Get New Display Styles...")
configFile: "systemmonitor-faces.knsrc"
onChangedEntriesChanged: controller.availableFacesModel.reload();
}
......
......@@ -94,7 +94,7 @@ ColumnLayout {
width: usedSensorsView.width
actions: Kirigami.Action {
icon.name: "list-remove"
text: i18n("Remove")
text: i18nd("KSysGuardSensorFaces", "Remove")
onTriggered: {
usedSensorsModel.remove(index, 1);
usedSensorsModel.save();
......@@ -133,11 +133,11 @@ ColumnLayout {
Layout.preferredHeight: sensorListHeader.implicitHeight
visible: controller.supportsTotalSensors
QQC2.Label {
text: i18n("Total Sensor:")
text: i18nd("KSysGuardSensorFaces", "Total Sensor:")
}
QQC2.Label {
Layout.fillWidth: true
text: cfg_totalSensors.length > 0 ? totalSensor.name : i18n("Drop Sensor Here")
text: cfg_totalSensors.length > 0 ? totalSensor.name : i18nd("KSysGuardSensorFaces", "Drop Sensor Here")
elide: Text.ElideRight
DropArea {
anchors.fill: parent
......@@ -174,7 +174,7 @@ ColumnLayout {
Kirigami.Heading {
Layout.preferredHeight: sensorListHeader.implicitHeight
level: 3
text: i18n("Chart Sensors")
text: i18nd("KSysGuardSensorFaces", "Chart Sensors")
}
Local.UsedSensorsView {
id: usedSensorsView
......@@ -183,7 +183,7 @@ ColumnLayout {
}
Kirigami.Heading {
Layout.preferredHeight: sensorListHeader.implicitHeight
text: i18n("Text Only Sensors")
text: i18nd("KSysGuardSensorFaces", "Text Only Sensors")
level: 3
visible: lowPrioritySensorsView.visible
}
......@@ -207,7 +207,7 @@ ColumnLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
level: 3
text: i18n("All Sensors")
text: i18nd("KSysGuardSensorFaces", "All Sensors")
}
}
Kirigami.SearchField {
......
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/KSysGuardSensorFaces.pot
......@@ -152,6 +152,7 @@ public:
bool configNeedsSave = false;
KPackage::Package facePackage;
QString faceId;
KLocalizedContext *contextObj = nullptr;
KConfigGroup configGroup;
KConfigGroup appearanceGroup;
KConfigGroup sensorsGroup;
......@@ -183,8 +184,8 @@ SensorFace *SensorFaceController::Private::createGui(const QString &qmlPath)
return nullptr;
}
//TODO: add i18n context object
QQmlContext *context = new QQmlContext(engine);
context->setContextObject(contextObj);
QObject *guiObject = component->beginCreate(context);
SensorFace *gui = qobject_cast<SensorFace *>(guiObject);
if (!gui) {
......@@ -193,7 +194,7 @@ SensorFace *SensorFaceController::Private::createGui(const QString &qmlPath)
context->deleteLater();
return nullptr;
}
// context->setParent(gui);
context->setParent(gui);
gui->setController(q);
......@@ -216,12 +217,13 @@ QQuickItem *SensorFaceController::Private::createConfigUi(const QString &file, c
return nullptr;
}
//TODO: add i18n context object
QQmlContext *context = new QQmlContext(engine);
context->setContextObject(contextObj);
QObject *guiObject = component->createWithInitialProperties(
initialProperties, context);
QQuickItem *gui = qobject_cast<QQuickItem *>(guiObject);
Q_ASSERT(gui);
context->setParent(gui);
component->deleteLater();
......@@ -398,6 +400,7 @@ void SensorFaceController::setFaceId(const QString &face)
d->facePackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KSysguard/SensorFace"), face);
d->contextObj->deleteLater();
if (d->faceConfiguration) {
d->faceConfiguration->deleteLater();
d->faceConfiguration = nullptr;
......@@ -412,6 +415,9 @@ void SensorFaceController::setFaceId(const QString &face)
return;
}
d->contextObj = new KLocalizedContext(d->engine);
d->contextObj->setTranslationDomain(QLatin1String("ksysguard_face_") + face);
//TODO: should be in a different config file rather than metadata
d->faceProperties = KConfigGroup(KSharedConfig::openConfig(d->facePackage.filePath("FaceProperties")), QStringLiteral("Config"));
......
......@@ -21,6 +21,7 @@
#include <QQuickItem>
#include <QStandardItemModel>
#include <KLocalizedContext>
class QQmlEngine;
......
......@@ -69,7 +69,7 @@ DropArea {
id: listItem
actions: Kirigami.Action {
icon.name: "list-remove"
text: i18n("Remove")
text: i18nd("KSysGuardSensorFaces", "Remove")
onTriggered: {
usedSensorsModel.remove(index, 1);
usedSensorsModel.save();
......@@ -131,7 +131,7 @@ DropArea {
anchors.centerIn: parent
z: 2
visible: usedSensorsView.count == 0
text: i18n("Drop Sensors Here")
text: i18nd("KSysGuardSensorFaces", "Drop Sensors Here")
}
Rectangle {
anchors {
......
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml` -o $podir/ksysguard_face_org.kde.ksysguard.barchart.pot
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml` -o $podir/ksysguard_face_org.kde.ksysguard.linechart.pot
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml` -o $podir/ksysguard_face_org.kde.ksysguard.piechart.pot
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml` -o $podir/ksysguard_face_org.kde.ksysguard.textonly.pot
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment