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_devicepluginelro.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/share/guh/translations/*.qm
|
||||
data/systemd/guhd.service /etc/systemd/system/
|
||||
data/logrotate/guhd /etc/logrotate.d/
|
||||
|
||||
@ -221,7 +221,7 @@ DeviceManager::DeviceManager(const QLocale &locale, QObject *parent) :
|
||||
m_avahiBrowser->enable();
|
||||
|
||||
// Bluetooth LE
|
||||
#ifdef BLUETOOTH_LE
|
||||
#ifdef BLUETOOTH_LE
|
||||
m_bluetoothScanner = new BluetoothScanner(this);
|
||||
if (!m_bluetoothScanner->isAvailable()) {
|
||||
delete m_bluetoothScanner;
|
||||
@ -229,7 +229,7 @@ DeviceManager::DeviceManager(const QLocale &locale, QObject *parent) :
|
||||
} else {
|
||||
connect(m_bluetoothScanner, &BluetoothScanner::bluetoothDiscoveryFinished, this, &DeviceManager::bluetoothDiscoveryFinished);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Give hardware a chance to start up before loading plugins etc.
|
||||
QMetaObject::invokeMethod(this, "loadPlugins", Qt::QueuedConnection);
|
||||
@ -968,9 +968,10 @@ void DeviceManager::loadPlugins()
|
||||
} else {
|
||||
fi.setFile(path + "/" + entry + "/libguh_deviceplugin" + entry + ".so");
|
||||
}
|
||||
if (!fi.exists()) {
|
||||
|
||||
if (!fi.exists())
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
QPluginLoader loader;
|
||||
loader.setFileName(fi.absoluteFilePath());
|
||||
@ -987,71 +988,68 @@ void DeviceManager::loadPlugins()
|
||||
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());
|
||||
|
||||
if (verifyPluginMetadata(loader.metaData().value("MetaData").toObject())) {
|
||||
pluginIface->initPlugin(loader.metaData().value("MetaData").toObject(), this);
|
||||
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);
|
||||
}
|
||||
if (!verifyPluginMetadata(loader.metaData().value("MetaData").toObject()))
|
||||
continue;
|
||||
|
||||
foreach (const DeviceClass &deviceClass, pluginIface->supportedDevices()) {
|
||||
if (!m_supportedVendors.contains(deviceClass.vendorId())) {
|
||||
qCWarning(dcDeviceManager) << "! Vendor not found. Ignoring device. VendorId:" << deviceClass.vendorId() << "DeviceClass:" << deviceClass.name() << deviceClass.id();
|
||||
continue;
|
||||
}
|
||||
m_vendorDeviceMap[deviceClass.vendorId()].append(deviceClass.id());
|
||||
m_supportedDevices.insert(deviceClass.id(), deviceClass);
|
||||
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
||||
pluginIface->initPlugin(loader.metaData().value("MetaData").toObject(), this);
|
||||
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);
|
||||
}
|
||||
|
||||
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
||||
settings.beginGroup("PluginConfig");
|
||||
ParamList params;
|
||||
if (settings.childGroups().contains(pluginIface->pluginId().toString())) {
|
||||
settings.beginGroup(pluginIface->pluginId().toString());
|
||||
foreach (const QString ¶mName, settings.allKeys()) {
|
||||
Param param(paramName, settings.value(paramName));
|
||||
params.append(param);
|
||||
}
|
||||
settings.endGroup();
|
||||
} else if (pluginIface->configurationDescription().count() > 0){
|
||||
// plugin requires config but none stored. Init with defaults
|
||||
foreach (const ParamType ¶mType, pluginIface->configurationDescription()) {
|
||||
Param param(paramType.name(), paramType.defaultValue());
|
||||
params.append(param);
|
||||
}
|
||||
foreach (const DeviceClass &deviceClass, pluginIface->supportedDevices()) {
|
||||
if (!m_supportedVendors.contains(deviceClass.vendorId())) {
|
||||
qCWarning(dcDeviceManager) << "Vendor not found. Ignoring device. VendorId:" << deviceClass.vendorId() << "DeviceClass:" << deviceClass.name() << deviceClass.id();
|
||||
continue;
|
||||
}
|
||||
m_vendorDeviceMap[deviceClass.vendorId()].append(deviceClass.id());
|
||||
m_supportedDevices.insert(deviceClass.id(), deviceClass);
|
||||
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
||||
}
|
||||
|
||||
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
||||
settings.beginGroup("PluginConfig");
|
||||
ParamList params;
|
||||
if (settings.childGroups().contains(pluginIface->pluginId().toString())) {
|
||||
settings.beginGroup(pluginIface->pluginId().toString());
|
||||
foreach (const QString ¶mName, settings.allKeys()) {
|
||||
Param param(paramName, settings.value(paramName));
|
||||
params.append(param);
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
if (params.count() > 0) {
|
||||
DeviceError status = pluginIface->setConfiguration(params);
|
||||
if (status != DeviceErrorNoError) {
|
||||
qCWarning(dcDeviceManager) << "Error setting params to plugin. Broken configuration?";
|
||||
}
|
||||
} else if (pluginIface->configurationDescription().count() > 0){
|
||||
// plugin requires config but none stored. Init with defaults
|
||||
foreach (const ParamType ¶mType, pluginIface->configurationDescription()) {
|
||||
Param param(paramType.name(), paramType.defaultValue());
|
||||
params.append(param);
|
||||
}
|
||||
}
|
||||
settings.endGroup();
|
||||
DeviceError status = pluginIface->setConfiguration(params);
|
||||
if (status != DeviceErrorNoError) {
|
||||
qWarning() << "Error setting params to plugin. Broken configuration?";
|
||||
|
||||
if (params.count() > 0) {
|
||||
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::devicesDiscovered, this, &DeviceManager::slotDevicesDiscovered, Qt::QueuedConnection);
|
||||
connect(pluginIface, &DevicePlugin::deviceSetupFinished, this, &DeviceManager::slotDeviceSetupFinished);
|
||||
connect(pluginIface, &DevicePlugin::actionExecutionFinished, this, &DeviceManager::actionExecutionFinished);
|
||||
connect(pluginIface, &DevicePlugin::pairingFinished, this, &DeviceManager::slotPairingFinished);
|
||||
connect(pluginIface, &DevicePlugin::autoDevicesAppeared, this, &DeviceManager::autoDevicesAppeared);
|
||||
}
|
||||
connect(pluginIface, &DevicePlugin::emitEvent, this, &DeviceManager::eventTriggered);
|
||||
connect(pluginIface, &DevicePlugin::devicesDiscovered, this, &DeviceManager::slotDevicesDiscovered, Qt::QueuedConnection);
|
||||
connect(pluginIface, &DevicePlugin::deviceSetupFinished, this, &DeviceManager::slotDeviceSetupFinished);
|
||||
connect(pluginIface, &DevicePlugin::actionExecutionFinished, this, &DeviceManager::actionExecutionFinished);
|
||||
connect(pluginIface, &DevicePlugin::pairingFinished, this, &DeviceManager::slotPairingFinished);
|
||||
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()) {
|
||||
QJsonObject jo = deviceClassJson.toObject();
|
||||
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;
|
||||
foreach (const QJsonValue &createMethodValue, jo.value("createMethods").toArray()) {
|
||||
if (createMethodValue.toString() == "discovery") {
|
||||
@ -238,7 +238,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
||||
"in deviceClass " << deviceClass.name() << ". Falling back to 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());
|
||||
if (!paramTypesVerification.first) {
|
||||
broken = true;
|
||||
@ -446,9 +446,9 @@ QTranslator *DevicePlugin::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.
|
||||
@ -864,6 +864,15 @@ QStringList DevicePlugin::verifyFields(const QStringList &fields, const QJsonObj
|
||||
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
|
||||
{
|
||||
if (unitString.isEmpty())
|
||||
|
||||
@ -62,7 +62,7 @@ public:
|
||||
QList<DeviceClass> supportedDevices() const;
|
||||
|
||||
QTranslator *translator();
|
||||
void setLocale(const QLocale &locale);
|
||||
bool setLocale(const QLocale &locale);
|
||||
|
||||
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
||||
|
||||
@ -135,6 +135,8 @@ private:
|
||||
|
||||
QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const;
|
||||
|
||||
QString translateValue(const QString &context, const QString &string) const;
|
||||
|
||||
// load and verify enum values
|
||||
QPair<bool, Types::Unit> loadAndVerifyUnit(const QString &unitString) 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);
|
||||
}
|
||||
|
||||
// Translator for the server application
|
||||
QTranslator translator;
|
||||
translator.load(QLocale::system(), application.applicationName(), "_", GuhSettings::translationsPath(), ".qm");
|
||||
qApp->installTranslator(&translator);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<context>
|
||||
<name>main</name>
|
||||
<message>
|
||||
<location filename="../server/main.cpp" line="136"/>
|
||||
<location filename="../server/main.cpp" line="141"/>
|
||||
<source>
|
||||
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
||||
which allows to control a lot of different devices from many different
|
||||
@ -23,12 +23,12 @@ Szenen undVerhaltensweisen des Systems festzulegen.
|
||||
</translation>
|
||||
</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>
|
||||
<translation>Starte guhd im Vordergrund, nicht als Service.</translation>
|
||||
</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".
|
||||
|
||||
Categories are:</source>
|
||||
@ -36,12 +36,12 @@ Categories are:</source>
|
||||
Es gibt folgende Kategorien:</translation>
|
||||
</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>
|
||||
<translation>Aktiviere alle Debug-Kategorien. Dieser Parameter überschreibt alle anderen Debug-Kategorien Parameter.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../server/main.cpp" line="188"/>
|
||||
<location filename="../server/main.cpp" line="193"/>
|
||||
<source>No such debug category:</source>
|
||||
<translation>Diese Debug-Kategorie existiert nicht:</translation>
|
||||
</message>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<context>
|
||||
<name>main</name>
|
||||
<message>
|
||||
<location filename="../server/main.cpp" line="136"/>
|
||||
<location filename="../server/main.cpp" line="141"/>
|
||||
<source>
|
||||
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
||||
which allows to control a lot of different devices from many different
|
||||
@ -16,24 +16,24 @@ for your environment.
|
||||
<translation type="unfinished"></translation>
|
||||
</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>
|
||||
<translation type="unfinished"></translation>
|
||||
</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".
|
||||
|
||||
Categories are:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</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>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../server/main.cpp" line="188"/>
|
||||
<location filename="../server/main.cpp" line="193"/>
|
||||
<source>No such debug category:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
Reference in New Issue
Block a user