From d3abd9bf9f2226bef0119f447d39566ee6f0c8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 17 Aug 2016 19:26:09 +0200 Subject: [PATCH] add guh-translations package --- debian/control | 19 +++++++++++++++++-- debian/guh-plugins-maker.dirs | 1 - debian/guh-plugins-merkur.dirs | 1 - debian/guh-plugins.dirs | 1 - debian/guh-translations.dirs | 1 + debian/guh-translations.install | 2 ++ debian/guhd.dirs | 1 - debian/guhd.install | 1 - libguh/devicemanager.cpp | 6 +++--- libguh/plugin/deviceplugin.cpp | 3 ++- plugins/plugins.pri | 2 +- server/main.cpp | 6 +++++- translations/guhd_de_DE.ts | 10 +++++----- translations/guhd_en_US.ts | 10 +++++----- 14 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 debian/guh-translations.dirs create mode 100644 debian/guh-translations.install diff --git a/debian/control b/debian/control index 971dbe93..1e257d61 100644 --- a/debian/control +++ b/debian/control @@ -19,7 +19,7 @@ Standards-Version: 3.9.5 Package: guh Architecture: any -Section: misc +Section: metapackages Depends: guhd (= ${binary:Version}), guh-plugins (= ${binary:Version}), Description: An open source IoT server - meta package @@ -31,6 +31,7 @@ Description: An open source IoT server - meta package Package: guhd Architecture: any +Section: net Depends: libqt5network5, libqt5gui5, libqt5sql5, @@ -39,6 +40,7 @@ Depends: libqt5network5, libqt5bluetooth5, logrotate, avahi-daemon, + guh-translations (= ${binary:Version}), libguh1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} @@ -73,12 +75,25 @@ Description: Documentation for the guh package (on-site) - documentation powerful rule engine you are able to connect any device available in the system and create individual scenes and behaviors for your home. +Package: guh-translations +Section: translations +Architecture: all +Depends: guh (= ${binary:Version}), + ${misc:Depends} +Recommends: guh (= ${binary:Version}) +Description: Documentation for the guh package (on-site) - documentation + guh is an open source home automation server, which allows to control + a lot of different devices from many different manufacturers. With the + powerful rule engine you are able to connect any device available in + the system and create individual scenes and behaviors for your home. + Package: guh-tests +Section: misc Architecture: any Depends: guh (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} -Description: Tests and mock plugin for the guh package +Description: Translation files for guh - translations guh is an open source IoT (Internet of Things) server, which allows to control a lot of different devices from many different manufacturers. With the powerful rule engine you are able to connect any diff --git a/debian/guh-plugins-maker.dirs b/debian/guh-plugins-maker.dirs index 40037615..0a803bb8 100644 --- a/debian/guh-plugins-maker.dirs +++ b/debian/guh-plugins-maker.dirs @@ -1,2 +1 @@ usr/lib/guh/plugins -usr/share/guh/translations diff --git a/debian/guh-plugins-merkur.dirs b/debian/guh-plugins-merkur.dirs index 40037615..0a803bb8 100644 --- a/debian/guh-plugins-merkur.dirs +++ b/debian/guh-plugins-merkur.dirs @@ -1,2 +1 @@ usr/lib/guh/plugins -usr/share/guh/translations diff --git a/debian/guh-plugins.dirs b/debian/guh-plugins.dirs index 40037615..0a803bb8 100644 --- a/debian/guh-plugins.dirs +++ b/debian/guh-plugins.dirs @@ -1,2 +1 @@ usr/lib/guh/plugins -usr/share/guh/translations diff --git a/debian/guh-translations.dirs b/debian/guh-translations.dirs new file mode 100644 index 00000000..667a6a9b --- /dev/null +++ b/debian/guh-translations.dirs @@ -0,0 +1 @@ +usr/share/guh/translations diff --git a/debian/guh-translations.install b/debian/guh-translations.install new file mode 100644 index 00000000..e513e702 --- /dev/null +++ b/debian/guh-translations.install @@ -0,0 +1,2 @@ +translations/*.qm usr/share/guh/translations + diff --git a/debian/guhd.dirs b/debian/guhd.dirs index 9092d70f..e5721b19 100644 --- a/debian/guhd.dirs +++ b/debian/guhd.dirs @@ -1,3 +1,2 @@ usr/bin etc/guh/ -usr/share/guh/translations diff --git a/debian/guhd.install b/debian/guhd.install index e3c0f2de..b3a74c6e 100644 --- a/debian/guhd.install +++ b/debian/guhd.install @@ -1,4 +1,3 @@ usr/bin/guhd data/systemd/guhd.service /etc/systemd/system/ data/logrotate/guhd /etc/logrotate.d/ -translations/*.qm /usr/share/guh/translations diff --git a/libguh/devicemanager.cpp b/libguh/devicemanager.cpp index 41d96aeb..6aa3c7e9 100644 --- a/libguh/devicemanager.cpp +++ b/libguh/devicemanager.cpp @@ -286,9 +286,9 @@ void DeviceManager::setLocale(const QLocale &locale) { m_locale = locale; foreach (DevicePlugin *plugin, m_devicePlugins.values()) { - if (!plugin->setLocale(m_locale)) - qCWarning(dcDeviceManager()) << "Could not load translation" << m_locale.name() << "for plugin" << plugin->pluginName(); - + QCoreApplication::removeTranslator(plugin->translator()); + plugin->setLocale(m_locale); + QCoreApplication::installTranslator(plugin->translator()); } } diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index 4f2121e2..ca8be590 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -451,7 +451,7 @@ QTranslator *DevicePlugin::translator() bool DevicePlugin::setLocale(const QLocale &locale) { // check if there are local translations - if (m_translator->load(locale, m_metaData.value("id").toString(), "-", QDir(QCoreApplication::applicationDirPath() + "../../plugins/translations/").absolutePath(), ".qm")) { + if (m_translator->load(locale, m_metaData.value("id").toString(), "-", QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(), ".qm")) { qCDebug(dcDeviceManager()) << "* Load translation" << locale.name() << "for" << pluginName() << "from" << QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(); return true; } @@ -462,6 +462,7 @@ bool DevicePlugin::setLocale(const QLocale &locale) return true; } + qCWarning(dcDeviceManager()) << "* Could not load translation" << locale.name() << "for plugin" << pluginName(); return false; } diff --git a/plugins/plugins.pri b/plugins/plugins.pri index 2b423bdb..974d2a58 100644 --- a/plugins/plugins.pri +++ b/plugins/plugins.pri @@ -23,7 +23,7 @@ infofile.commands = $$top_srcdir/plugins/guh-generateplugininfo -j ${QMAKE_FILE_ -o ${QMAKE_FILE_OUT} \ -b $$OUT_PWD \ -t $$TRANSLATIONS; \ - rsync -a "$$OUT_PWD"/translations/*.qm $$top_builddir/plugins/translations/; + rsync -a "$$OUT_PWD"/translations/*.qm $$top_builddir/translations/; QMAKE_EXTRA_COMPILERS += infofile PRE_TARGETDEPS += compiler_infofile_make_all diff --git a/server/main.cpp b/server/main.cpp index 07291bbe..6f57ad71 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -132,7 +132,11 @@ int main(int argc, char *argv[]) // Translator for the server application QTranslator translator; - translator.load(QLocale::system(), application.applicationName(), "_", GuhSettings::translationsPath(), ".qm"); + // check if there are local translations + if (!translator.load(QLocale::system(), application.applicationName(), "-", QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(), ".qm")) + if (!translator.load(QLocale::system(), application.applicationName(), "-", GuhSettings::translationsPath(), ".qm")) + qWarning(dcApplication()) << "Could not find guhd translations for" << QLocale::system(); + qApp->installTranslator(&translator); QCommandLineParser parser; diff --git a/translations/guhd_de_DE.ts b/translations/guhd_de_DE.ts index b5276c5a..db488d4e 100644 --- a/translations/guhd_de_DE.ts +++ b/translations/guhd_de_DE.ts @@ -4,7 +4,7 @@ main - + 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. - + Run guhd in the foreground, not as daemon. Starte guhd im Vordergrund, nicht als Service. - + Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings". Categories are: @@ -36,12 +36,12 @@ Categories are: Es gibt folgende Kategorien: - + Enables all debug categories. This parameter overrides all debug category parameters. Aktiviere alle Debug-Kategorien. Dieser Parameter überschreibt alle anderen Debug-Kategorien Parameter. - + No such debug category: Diese Debug-Kategorie existiert nicht: diff --git a/translations/guhd_en_US.ts b/translations/guhd_en_US.ts index 9ef4f030..949bde78 100644 --- a/translations/guhd_en_US.ts +++ b/translations/guhd_en_US.ts @@ -4,7 +4,7 @@ main - + 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. - + Run guhd in the foreground, not as daemon. - + Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings". Categories are: - + Enables all debug categories. This parameter overrides all debug category parameters. - + No such debug category: