experiment with translation install path
This commit is contained in:
parent
e7a2cec8c2
commit
8f28d75120
2
debian/guh-plugins.install
vendored
2
debian/guh-plugins.install
vendored
@ -1,5 +1,3 @@
|
|||||||
usr/share/guh/translations/*.qm
|
|
||||||
|
|
||||||
usr/lib/guh/plugins/libguh_devicepluginconrad.so
|
usr/lib/guh/plugins/libguh_devicepluginconrad.so
|
||||||
usr/lib/guh/plugins/libguh_devicepluginelro.so
|
usr/lib/guh/plugins/libguh_devicepluginelro.so
|
||||||
usr/lib/guh/plugins/libguh_deviceplugineq3.so
|
usr/lib/guh/plugins/libguh_deviceplugineq3.so
|
||||||
|
|||||||
1
debian/guhd.install
vendored
1
debian/guhd.install
vendored
@ -1,4 +1,3 @@
|
|||||||
usr/bin/guhd
|
usr/bin/guhd
|
||||||
usr/share/guh/translations/*.qm
|
|
||||||
data/systemd/guhd.service /etc/systemd/system/
|
data/systemd/guhd.service /etc/systemd/system/
|
||||||
data/logrotate/guhd /etc/logrotate.d/
|
data/logrotate/guhd /etc/logrotate.d/
|
||||||
|
|||||||
@ -221,7 +221,7 @@ DeviceManager::DeviceManager(const QLocale &locale, QObject *parent) :
|
|||||||
m_avahiBrowser->enable();
|
m_avahiBrowser->enable();
|
||||||
|
|
||||||
// Bluetooth LE
|
// Bluetooth LE
|
||||||
#ifdef BLUETOOTH_LE
|
#ifdef BLUETOOTH_LE
|
||||||
m_bluetoothScanner = new BluetoothScanner(this);
|
m_bluetoothScanner = new BluetoothScanner(this);
|
||||||
if (!m_bluetoothScanner->isAvailable()) {
|
if (!m_bluetoothScanner->isAvailable()) {
|
||||||
delete m_bluetoothScanner;
|
delete m_bluetoothScanner;
|
||||||
@ -229,7 +229,7 @@ DeviceManager::DeviceManager(const QLocale &locale, QObject *parent) :
|
|||||||
} else {
|
} else {
|
||||||
connect(m_bluetoothScanner, &BluetoothScanner::bluetoothDiscoveryFinished, this, &DeviceManager::bluetoothDiscoveryFinished);
|
connect(m_bluetoothScanner, &BluetoothScanner::bluetoothDiscoveryFinished, this, &DeviceManager::bluetoothDiscoveryFinished);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Give hardware a chance to start up before loading plugins etc.
|
// Give hardware a chance to start up before loading plugins etc.
|
||||||
QMetaObject::invokeMethod(this, "loadPlugins", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "loadPlugins", Qt::QueuedConnection);
|
||||||
@ -968,9 +968,10 @@ void DeviceManager::loadPlugins()
|
|||||||
} else {
|
} else {
|
||||||
fi.setFile(path + "/" + entry + "/libguh_deviceplugin" + entry + ".so");
|
fi.setFile(path + "/" + entry + "/libguh_deviceplugin" + entry + ".so");
|
||||||
}
|
}
|
||||||
if (!fi.exists()) {
|
|
||||||
|
if (!fi.exists())
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
QPluginLoader loader;
|
QPluginLoader loader;
|
||||||
loader.setFileName(fi.absoluteFilePath());
|
loader.setFileName(fi.absoluteFilePath());
|
||||||
@ -987,71 +988,68 @@ void DeviceManager::loadPlugins()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginIface->setLocale(m_locale);
|
if (!pluginIface->setLocale(m_locale))
|
||||||
|
qCWarning(dcDeviceManager()) << "Could not load translation" << m_locale.name() << "for plugin" << pluginIface->pluginName();
|
||||||
|
|
||||||
qApp->installTranslator(pluginIface->translator());
|
qApp->installTranslator(pluginIface->translator());
|
||||||
|
|
||||||
if (verifyPluginMetadata(loader.metaData().value("MetaData").toObject())) {
|
if (!verifyPluginMetadata(loader.metaData().value("MetaData").toObject()))
|
||||||
pluginIface->initPlugin(loader.metaData().value("MetaData").toObject(), this);
|
continue;
|
||||||
qCDebug(dcDeviceManager) << "**** Loaded plugin" << pluginIface->pluginName();
|
|
||||||
foreach (const Vendor &vendor, pluginIface->supportedVendors()) {
|
|
||||||
qCDebug(dcDeviceManager) << "* Loaded vendor:" << vendor.name();
|
|
||||||
if (m_supportedVendors.contains(vendor.id())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
m_supportedVendors.insert(vendor.id(), vendor);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const DeviceClass &deviceClass, pluginIface->supportedDevices()) {
|
pluginIface->initPlugin(loader.metaData().value("MetaData").toObject(), this);
|
||||||
if (!m_supportedVendors.contains(deviceClass.vendorId())) {
|
qCDebug(dcDeviceManager) << "**** Loaded plugin" << pluginIface->pluginName();
|
||||||
qCWarning(dcDeviceManager) << "! Vendor not found. Ignoring device. VendorId:" << deviceClass.vendorId() << "DeviceClass:" << deviceClass.name() << deviceClass.id();
|
foreach (const Vendor &vendor, pluginIface->supportedVendors()) {
|
||||||
continue;
|
qCDebug(dcDeviceManager) << "* Loaded vendor:" << vendor.name();
|
||||||
}
|
if (m_supportedVendors.contains(vendor.id())) {
|
||||||
m_vendorDeviceMap[deviceClass.vendorId()].append(deviceClass.id());
|
continue;
|
||||||
m_supportedDevices.insert(deviceClass.id(), deviceClass);
|
|
||||||
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
|
||||||
}
|
}
|
||||||
|
m_supportedVendors.insert(vendor.id(), vendor);
|
||||||
|
}
|
||||||
|
|
||||||
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
foreach (const DeviceClass &deviceClass, pluginIface->supportedDevices()) {
|
||||||
settings.beginGroup("PluginConfig");
|
if (!m_supportedVendors.contains(deviceClass.vendorId())) {
|
||||||
ParamList params;
|
qCWarning(dcDeviceManager) << "Vendor not found. Ignoring device. VendorId:" << deviceClass.vendorId() << "DeviceClass:" << deviceClass.name() << deviceClass.id();
|
||||||
if (settings.childGroups().contains(pluginIface->pluginId().toString())) {
|
continue;
|
||||||
settings.beginGroup(pluginIface->pluginId().toString());
|
}
|
||||||
foreach (const QString ¶mName, settings.allKeys()) {
|
m_vendorDeviceMap[deviceClass.vendorId()].append(deviceClass.id());
|
||||||
Param param(paramName, settings.value(paramName));
|
m_supportedDevices.insert(deviceClass.id(), deviceClass);
|
||||||
params.append(param);
|
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
|
||||||
} else if (pluginIface->configurationDescription().count() > 0){
|
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
||||||
// plugin requires config but none stored. Init with defaults
|
settings.beginGroup("PluginConfig");
|
||||||
foreach (const ParamType ¶mType, pluginIface->configurationDescription()) {
|
ParamList params;
|
||||||
Param param(paramType.name(), paramType.defaultValue());
|
if (settings.childGroups().contains(pluginIface->pluginId().toString())) {
|
||||||
params.append(param);
|
settings.beginGroup(pluginIface->pluginId().toString());
|
||||||
}
|
foreach (const QString ¶mName, settings.allKeys()) {
|
||||||
|
Param param(paramName, settings.value(paramName));
|
||||||
|
params.append(param);
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
} else if (pluginIface->configurationDescription().count() > 0){
|
||||||
if (params.count() > 0) {
|
// plugin requires config but none stored. Init with defaults
|
||||||
DeviceError status = pluginIface->setConfiguration(params);
|
foreach (const ParamType ¶mType, pluginIface->configurationDescription()) {
|
||||||
if (status != DeviceErrorNoError) {
|
Param param(paramType.name(), paramType.defaultValue());
|
||||||
qCWarning(dcDeviceManager) << "Error setting params to plugin. Broken configuration?";
|
params.append(param);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
DeviceError status = pluginIface->setConfiguration(params);
|
|
||||||
if (status != DeviceErrorNoError) {
|
if (params.count() > 0) {
|
||||||
qWarning() << "Error setting params to plugin. Broken configuration?";
|
DeviceError status = pluginIface->setConfiguration(params);
|
||||||
|
if (status != DeviceErrorNoError) {
|
||||||
|
qCWarning(dcDeviceManager) << "Error setting params to plugin. Broken configuration?";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devicePlugins.insert(pluginIface->pluginId(), pluginIface);
|
m_devicePlugins.insert(pluginIface->pluginId(), pluginIface);
|
||||||
|
|
||||||
connect(pluginIface, &DevicePlugin::emitEvent, this, &DeviceManager::eventTriggered);
|
connect(pluginIface, &DevicePlugin::emitEvent, this, &DeviceManager::eventTriggered);
|
||||||
connect(pluginIface, &DevicePlugin::devicesDiscovered, this, &DeviceManager::slotDevicesDiscovered, Qt::QueuedConnection);
|
connect(pluginIface, &DevicePlugin::devicesDiscovered, this, &DeviceManager::slotDevicesDiscovered, Qt::QueuedConnection);
|
||||||
connect(pluginIface, &DevicePlugin::deviceSetupFinished, this, &DeviceManager::slotDeviceSetupFinished);
|
connect(pluginIface, &DevicePlugin::deviceSetupFinished, this, &DeviceManager::slotDeviceSetupFinished);
|
||||||
connect(pluginIface, &DevicePlugin::actionExecutionFinished, this, &DeviceManager::actionExecutionFinished);
|
connect(pluginIface, &DevicePlugin::actionExecutionFinished, this, &DeviceManager::actionExecutionFinished);
|
||||||
connect(pluginIface, &DevicePlugin::pairingFinished, this, &DeviceManager::slotPairingFinished);
|
connect(pluginIface, &DevicePlugin::pairingFinished, this, &DeviceManager::slotPairingFinished);
|
||||||
connect(pluginIface, &DevicePlugin::autoDevicesAppeared, this, &DeviceManager::autoDevicesAppeared);
|
connect(pluginIface, &DevicePlugin::autoDevicesAppeared, this, &DeviceManager::autoDevicesAppeared);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -196,7 +196,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
|||||||
foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
|
foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
|
||||||
QJsonObject jo = deviceClassJson.toObject();
|
QJsonObject jo = deviceClassJson.toObject();
|
||||||
DeviceClass deviceClass(pluginId(), vendorId, jo.value("deviceClassId").toString());
|
DeviceClass deviceClass(pluginId(), vendorId, jo.value("deviceClassId").toString());
|
||||||
deviceClass.setName(jo.value("name").toString());
|
deviceClass.setName(translateValue(m_metaData.value("idName").toString(), jo.value("name").toString()));
|
||||||
DeviceClass::CreateMethods createMethods;
|
DeviceClass::CreateMethods createMethods;
|
||||||
foreach (const QJsonValue &createMethodValue, jo.value("createMethods").toArray()) {
|
foreach (const QJsonValue &createMethodValue, jo.value("createMethods").toArray()) {
|
||||||
if (createMethodValue.toString() == "discovery") {
|
if (createMethodValue.toString() == "discovery") {
|
||||||
@ -238,7 +238,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
|||||||
"in deviceClass " << deviceClass.name() << ". Falling back to SetupMethodJustAdd.";
|
"in deviceClass " << deviceClass.name() << ". Falling back to SetupMethodJustAdd.";
|
||||||
deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd);
|
deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd);
|
||||||
}
|
}
|
||||||
deviceClass.setPairingInfo(jo.value("pairingInfo").toString());
|
deviceClass.setPairingInfo(translateValue(m_metaData.value("idName").toString(), jo.value("pairingInfo").toString()));
|
||||||
QPair<bool, QList<ParamType> > paramTypesVerification = parseParamTypes(jo.value("paramTypes").toArray());
|
QPair<bool, QList<ParamType> > paramTypesVerification = parseParamTypes(jo.value("paramTypes").toArray());
|
||||||
if (!paramTypesVerification.first) {
|
if (!paramTypesVerification.first) {
|
||||||
broken = true;
|
broken = true;
|
||||||
@ -446,9 +446,9 @@ QTranslator *DevicePlugin::translator()
|
|||||||
return m_translator;
|
return m_translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePlugin::setLocale(const QLocale &locale)
|
bool DevicePlugin::setLocale(const QLocale &locale)
|
||||||
{
|
{
|
||||||
m_translator->load(locale, "mock", "_", GuhSettings::translationsPath(), ".qm");
|
return m_translator->load(locale, "mock", "_", GuhSettings::translationsPath(), ".qm");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
||||||
@ -864,6 +864,15 @@ QStringList DevicePlugin::verifyFields(const QStringList &fields, const QJsonObj
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DevicePlugin::translateValue(const QString &context, const QString &string) const
|
||||||
|
{
|
||||||
|
QString translation = m_translator->translate(context.toUtf8().constData(), string.toUtf8().constData());
|
||||||
|
if (translation.isEmpty())
|
||||||
|
translation = string;
|
||||||
|
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
|
||||||
QPair<bool, Types::Unit> DevicePlugin::loadAndVerifyUnit(const QString &unitString) const
|
QPair<bool, Types::Unit> DevicePlugin::loadAndVerifyUnit(const QString &unitString) const
|
||||||
{
|
{
|
||||||
if (unitString.isEmpty())
|
if (unitString.isEmpty())
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public:
|
|||||||
QList<DeviceClass> supportedDevices() const;
|
QList<DeviceClass> supportedDevices() const;
|
||||||
|
|
||||||
QTranslator *translator();
|
QTranslator *translator();
|
||||||
void setLocale(const QLocale &locale);
|
bool setLocale(const QLocale &locale);
|
||||||
|
|
||||||
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
||||||
|
|
||||||
@ -135,6 +135,8 @@ private:
|
|||||||
|
|
||||||
QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const;
|
QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const;
|
||||||
|
|
||||||
|
QString translateValue(const QString &context, const QString &string) const;
|
||||||
|
|
||||||
// load and verify enum values
|
// load and verify enum values
|
||||||
QPair<bool, Types::Unit> loadAndVerifyUnit(const QString &unitString) const;
|
QPair<bool, Types::Unit> loadAndVerifyUnit(const QString &unitString) const;
|
||||||
QPair<bool, Types::InputType> loadAndVerifyInputType(const QString &inputType) const;
|
QPair<bool, Types::InputType> loadAndVerifyInputType(const QString &inputType) const;
|
||||||
|
|||||||
@ -130,6 +130,11 @@ int main(int argc, char *argv[])
|
|||||||
loggingFiltersPlugins.insert(pluginMetadata.value("idName").toString(), false);
|
loggingFiltersPlugins.insert(pluginMetadata.value("idName").toString(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Translator for the server application
|
||||||
|
QTranslator translator;
|
||||||
|
translator.load(QLocale::system(), application.applicationName(), "_", GuhSettings::translationsPath(), ".qm");
|
||||||
|
qApp->installTranslator(&translator);
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>main</name>
|
<name>main</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="136"/>
|
<location filename="../server/main.cpp" line="141"/>
|
||||||
<source>
|
<source>
|
||||||
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
||||||
which allows to control a lot of different devices from many different
|
which allows to control a lot of different devices from many different
|
||||||
@ -23,12 +23,12 @@ Szenen undVerhaltensweisen des Systems festzulegen.
|
|||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="148"/>
|
<location filename="../server/main.cpp" line="153"/>
|
||||||
<source>Run guhd in the foreground, not as daemon.</source>
|
<source>Run guhd in the foreground, not as daemon.</source>
|
||||||
<translation>Starte guhd im Vordergrund, nicht als Service.</translation>
|
<translation>Starte guhd im Vordergrund, nicht als Service.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="151"/>
|
<location filename="../server/main.cpp" line="156"/>
|
||||||
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
||||||
|
|
||||||
Categories are:</source>
|
Categories are:</source>
|
||||||
@ -36,12 +36,12 @@ Categories are:</source>
|
|||||||
Es gibt folgende Kategorien:</translation>
|
Es gibt folgende Kategorien:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="168"/>
|
<location filename="../server/main.cpp" line="173"/>
|
||||||
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
||||||
<translation>Aktiviere alle Debug-Kategorien. Dieser Parameter überschreibt alle anderen Debug-Kategorien Parameter.</translation>
|
<translation>Aktiviere alle Debug-Kategorien. Dieser Parameter überschreibt alle anderen Debug-Kategorien Parameter.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="188"/>
|
<location filename="../server/main.cpp" line="193"/>
|
||||||
<source>No such debug category:</source>
|
<source>No such debug category:</source>
|
||||||
<translation>Diese Debug-Kategorie existiert nicht:</translation>
|
<translation>Diese Debug-Kategorie existiert nicht:</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>main</name>
|
<name>main</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="136"/>
|
<location filename="../server/main.cpp" line="141"/>
|
||||||
<source>
|
<source>
|
||||||
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
||||||
which allows to control a lot of different devices from many different
|
which allows to control a lot of different devices from many different
|
||||||
@ -16,24 +16,24 @@ for your environment.
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="148"/>
|
<location filename="../server/main.cpp" line="153"/>
|
||||||
<source>Run guhd in the foreground, not as daemon.</source>
|
<source>Run guhd in the foreground, not as daemon.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="151"/>
|
<location filename="../server/main.cpp" line="156"/>
|
||||||
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
||||||
|
|
||||||
Categories are:</source>
|
Categories are:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="168"/>
|
<location filename="../server/main.cpp" line="173"/>
|
||||||
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="188"/>
|
<location filename="../server/main.cpp" line="193"/>
|
||||||
<source>No such debug category:</source>
|
<source>No such debug category:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|||||||
Reference in New Issue
Block a user