mirror of https://github.com/nymea/nymea.git
update plugininfo compiler
parent
8f28d75120
commit
503939b559
|
|
@ -282,6 +282,16 @@ QList<QJsonObject> DeviceManager::pluginsMetadata()
|
|||
return pluginList;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*! Returns all the \l{DevicePlugin}{DevicePlugins} loaded in the system. */
|
||||
QList<DevicePlugin *> DeviceManager::plugins() const
|
||||
{
|
||||
|
|
@ -988,11 +998,6 @@ void DeviceManager::loadPlugins()
|
|||
continue;
|
||||
}
|
||||
|
||||
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()))
|
||||
continue;
|
||||
|
||||
|
|
@ -1016,6 +1021,11 @@ void DeviceManager::loadPlugins()
|
|||
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
||||
}
|
||||
|
||||
if (!pluginIface->setLocale(m_locale))
|
||||
qCWarning(dcDeviceManager()) << "Could not load translation" << m_locale.name() << "for plugin" << pluginIface->pluginName();
|
||||
|
||||
qApp->installTranslator(pluginIface->translator());
|
||||
|
||||
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
||||
settings.beginGroup("PluginConfig");
|
||||
ParamList params;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ public:
|
|||
static QStringList pluginSearchDirs();
|
||||
static QList<QJsonObject> pluginsMetadata();
|
||||
|
||||
void setLocale(const QLocale &locale);
|
||||
|
||||
QList<DevicePlugin*> plugins() const;
|
||||
DevicePlugin* plugin(const PluginId &id) const;
|
||||
DeviceError setPluginConfig(const PluginId &pluginId, const ParamList &pluginConfig);
|
||||
|
|
|
|||
|
|
@ -144,6 +144,8 @@
|
|||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QJsonArray>
|
||||
|
||||
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
||||
|
|
@ -448,7 +450,19 @@ QTranslator *DevicePlugin::translator()
|
|||
|
||||
bool DevicePlugin::setLocale(const QLocale &locale)
|
||||
{
|
||||
return m_translator->load(locale, "mock", "_", GuhSettings::translationsPath(), ".qm");
|
||||
// check if there are local translations
|
||||
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;
|
||||
}
|
||||
|
||||
// otherwise use the system translations
|
||||
if (m_translator->load(locale, m_metaData.value("id").toString(), "-", GuhSettings::translationsPath(), ".qm")) {
|
||||
qCDebug(dcDeviceManager()) << "* Load translation" << locale.name() << "for" << pluginName() << "from" << GuhSettings::translationsPath();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
TRANSLATIONS = translations/mock_en_US.ts \
|
||||
translations/mock_de_DE.ts
|
||||
TRANSLATIONS = translations/en_US.ts \
|
||||
translations/de_DE.ts
|
||||
|
||||
# Note: include after the TRANSLATIONS definition
|
||||
include(../../plugins.pri)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ outputFile = open(args.builddir + "/" + args.output, "w")
|
|||
outputFileExtern = open(args.builddir + "/" + "extern-" + args.output, "w")
|
||||
|
||||
# Read json file
|
||||
|
||||
try:
|
||||
pluginMap = json.loads(inputFile.read())
|
||||
inputFile.close()
|
||||
|
|
@ -72,6 +71,7 @@ except ValueError as error:
|
|||
inputFile.close()
|
||||
exit -1
|
||||
|
||||
##################################################################################################################
|
||||
# Methods
|
||||
|
||||
def writePluginInfo(line):
|
||||
|
|
@ -213,11 +213,15 @@ def writeTranslationStrings():
|
|||
def createTranslationFiles():
|
||||
for translation in args.translations:
|
||||
translationFile = (sourceDir + "/" + translation)
|
||||
translationOutput = os.path.splitext(translationFile)[0] + '.qm'
|
||||
print " --> Translation update %s" % translationFile
|
||||
print subprocess.check_output(['lupdate', '-recursive', sourceDir, (args.builddir + "/" + args.output), '-ts', translationFile])
|
||||
print " --> Translation release %s" % translationOutput
|
||||
print subprocess.check_output(['lrelease', translationFile, '-qm', translationOutput])
|
||||
path, fileName = os.path.split(translationFile)
|
||||
translationOutput = (path + "/" + pluginMap['id'] + '-' + os.path.splitext(fileName)[0] + '.qm')
|
||||
print(" --> Translation update %s" % translationFile)
|
||||
print(subprocess.check_output(['lupdate', '-recursive', '-no-obsolete', sourceDir, (args.builddir + "/" + args.output), '-ts', translationFile]))
|
||||
print(" --> Translation release %s" % translationOutput)
|
||||
print(subprocess.check_output(['lrelease', translationFile, '-qm', translationOutput]))
|
||||
print(" --> Copy translation files to build dir %s" % args.builddir + '/translations/')
|
||||
subprocess.check_output(['rsync', '-a', translationOutput, args.builddir + '/translations/'])
|
||||
|
||||
|
||||
##################################################################################################################
|
||||
# write plugininfo.h
|
||||
|
|
@ -227,8 +231,7 @@ print " --> generate plugininfo.h for plugin \"%s\" = %s" % (pluginMap['name'],
|
|||
writePluginInfo("/* This file is generated by the guh build system. Any changes to this file will")
|
||||
writePluginInfo(" * be lost.")
|
||||
writePluginInfo(" *")
|
||||
writePluginInfo(" * If you want to change this file, edit the plugin's json file and add")
|
||||
writePluginInfo(" * idName tags where appropriate.")
|
||||
writePluginInfo(" * If you want to change this file, edit the plugin's json file.")
|
||||
writePluginInfo(" */")
|
||||
writePluginInfo("")
|
||||
writePluginInfo("#ifndef PLUGININFO_H")
|
||||
|
|
@ -262,11 +265,6 @@ writePluginInfo("#endif // PLUGININFO_H")
|
|||
outputFile.close()
|
||||
print " --> generated successfully \"%s\"" % (args.output)
|
||||
|
||||
##################################################################################################################
|
||||
# Translate
|
||||
if len(translationStrings) is not 0:
|
||||
createTranslationFiles()
|
||||
|
||||
##################################################################################################################
|
||||
# Write extern-plugininfo.h
|
||||
|
||||
|
|
@ -300,5 +298,10 @@ writeExternPluginInfo("#endif // EXTERNPLUGININFO_H")
|
|||
outputFileExtern.close()
|
||||
print " --> generated successfully \"extern-%s\"" % (args.output)
|
||||
|
||||
##################################################################################################################
|
||||
# Translate
|
||||
if len(translationStrings) is not 0:
|
||||
createTranslationFiles()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ infofile.input = JSONFILES
|
|||
infofile.commands = $$top_srcdir/plugins/guh-generateplugininfo -j ${QMAKE_FILE_NAME} \
|
||||
-o ${QMAKE_FILE_OUT} \
|
||||
-b $$OUT_PWD \
|
||||
-t $$TRANSLATIONS
|
||||
-t $$TRANSLATIONS; \
|
||||
rsync -a "$$OUT_PWD"/translations/*.qm $$top_builddir/translations/;
|
||||
|
||||
QMAKE_EXTRA_COMPILERS += infofile
|
||||
|
||||
|
|
|
|||
|
|
@ -456,6 +456,8 @@ GuhCore::GuhCore(QObject *parent) :
|
|||
connect(m_configuration, &GuhConfiguration::cloudProxyServerChanged, m_cloudManager, &CloudManager::onProxyServerUrlChanged);
|
||||
connect(m_configuration, &GuhConfiguration::cloudAuthenticationServerChanged, m_cloudManager, &CloudManager::onAuthenticationServerUrlChanged);
|
||||
|
||||
connect(m_configuration, &GuhConfiguration::localeChanged, this, &GuhCore::onLocaleChanged);
|
||||
|
||||
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &GuhCore::gotEvent);
|
||||
connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &GuhCore::deviceStateChanged);
|
||||
connect(m_deviceManager, &DeviceManager::deviceAdded, this, &GuhCore::deviceAdded);
|
||||
|
|
@ -559,6 +561,11 @@ void GuhCore::onDateTimeChanged(const QDateTime &dateTime)
|
|||
executeRuleActions(actions);
|
||||
}
|
||||
|
||||
void GuhCore::onLocaleChanged()
|
||||
{
|
||||
m_deviceManager->setLocale(m_configuration->locale());
|
||||
}
|
||||
|
||||
/*! Return the instance of the log engine */
|
||||
LogEngine* GuhCore::logEngine() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ private:
|
|||
private slots:
|
||||
void gotEvent(const Event &event);
|
||||
void onDateTimeChanged(const QDateTime &dateTime);
|
||||
void onLocaleChanged();
|
||||
void actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status);
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ TRANSLATIONS *= $$top_srcdir/translations/guhd_en_US.ts \
|
|||
lrelease.input = TRANSLATIONS
|
||||
lrelease.CONFIG += no_link
|
||||
lrelease.output = $$top_srcdir/${QMAKE_FILE_BASE}.qm
|
||||
lrelease.commands = $$[QT_INSTALL_BINS]/lupdate $$_FILE_; \
|
||||
$$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm;
|
||||
lrelease.commands = $$[QT_INSTALL_BINS]/lupdate -no-obsolete $$_FILE_; \
|
||||
$$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm; \
|
||||
rsync -a $$top_srcdir/translations/*.qm $$top_builddir/translations/;
|
||||
|
||||
QMAKE_EXTRA_COMPILERS += lrelease
|
||||
PRE_TARGETDEPS += compiler_lrelease_make_all
|
||||
|
|
|
|||
Loading…
Reference in New Issue