diff --git a/debian/changelog b/debian/changelog index f8cd6efc..fd9c2818 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ guh (0.7.6) xenial; urgency=medium + * Add translations * Add bluetooth server -- Simon Stürz Wed, 14 Sep 2016 15:43:22 +0200 diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index 3d151fe8..1dfce369 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -448,7 +448,7 @@ QTranslator *DevicePlugin::translator() void DevicePlugin::setLocale(const QLocale &locale) { - m_translator->load(locale, pluginName(), "_", GuhSettings::translationsPath(), ".qm"); + m_translator->load(locale, "mock", "_", GuhSettings::translationsPath(), ".qm"); } /*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto. diff --git a/plugins/deviceplugins/awattar/devicepluginawattar.json b/plugins/deviceplugins/awattar/devicepluginawattar.json index 1288a5fc..0eed0c96 100644 --- a/plugins/deviceplugins/awattar/devicepluginawattar.json +++ b/plugins/deviceplugins/awattar/devicepluginawattar.json @@ -79,7 +79,7 @@ { "id": "55d6d7a8-446f-48ae-8014-1225810d03ee", "idName": "averagePrice", - "name": "average market price [± 12 h]", + "name": "average market price [+/- 12 h]", "index": 3, "type": "double", "unit": "EuroCentPerKiloWattHour", @@ -89,7 +89,7 @@ { "id": "e7af5bdc-48d7-4e96-b877-331da4dcfae5", "idName": "lowestPrice", - "name": "lowest market price [± 12 h]", + "name": "lowest market price [+/- 12 h]", "index": 4, "type": "double", "unit": "EuroCentPerKiloWattHour", @@ -100,7 +100,7 @@ { "id": "0c171c42-b070-453e-8a63-df9aebfa8533", "idName": "highestPrice", - "name": "highest market price [± 12 h]", + "name": "highest market price [+/- 12 h]", "index": 5, "type": "double", "unit": "EuroCentPerKiloWattHour", diff --git a/plugins/deviceplugins/commandlauncher/commandlauncher.pro b/plugins/deviceplugins/commandlauncher/commandlauncher.pro index 6de36aa5..65c00415 100644 --- a/plugins/deviceplugins/commandlauncher/commandlauncher.pro +++ b/plugins/deviceplugins/commandlauncher/commandlauncher.pro @@ -1,4 +1,5 @@ include (../../plugins.pri) + TARGET = $$qtLibraryTarget(guh_deviceplugincommandlauncher) SOURCES += \ diff --git a/plugins/deviceplugins/mock/devicepluginmock.cpp b/plugins/deviceplugins/mock/devicepluginmock.cpp index b607a204..39b3280c 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.cpp +++ b/plugins/deviceplugins/mock/devicepluginmock.cpp @@ -211,7 +211,7 @@ DeviceManager::DeviceError DevicePluginMock::displayPin(const PairingTransaction Q_UNUSED(pairingTransactionId) Q_UNUSED(deviceDescriptor) - qCDebug(dcMockDevice) << "Display pin!! The pin is 243681"; + qCDebug(dcMockDevice) << QString(tr("Display pin!! The pin is 243681")); return DeviceManager::DeviceErrorNoError; } diff --git a/plugins/deviceplugins/mock/devicepluginmock.json b/plugins/deviceplugins/mock/devicepluginmock.json index f7a108d7..7b802960 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.json +++ b/plugins/deviceplugins/mock/devicepluginmock.json @@ -1,6 +1,7 @@ { "name": "Mock Devices", "idName": "MockDevice", + "translationPrefix": "mock", "id": "727a4a9a-c187-446f-aadf-f1b2220607d1", "paramTypes": [ { diff --git a/plugins/deviceplugins/mock/mock.pro b/plugins/deviceplugins/mock/mock.pro index 3c692404..cabf1759 100644 --- a/plugins/deviceplugins/mock/mock.pro +++ b/plugins/deviceplugins/mock/mock.pro @@ -1,3 +1,7 @@ +TRANSLATIONS = translations/mock_en_US.ts \ + translations/mock_de_DE.ts + +# Note: include after the TRANSLATIONS definition include(../../plugins.pri) QT+= network @@ -11,5 +15,3 @@ SOURCES += \ HEADERS += \ devicepluginmock.h \ httpdaemon.h - - diff --git a/plugins/deviceplugins/mock/translations/mock_de_DE.ts b/plugins/deviceplugins/mock/translations/mock_de_DE.ts new file mode 100644 index 00000000..07bd6021 --- /dev/null +++ b/plugins/deviceplugins/mock/translations/mock_de_DE.ts @@ -0,0 +1,153 @@ + + + + + DevicePluginMock + + + Display pin!! The pin is 243681 + Pin anzeigen!! Der pin lautet 243581 + + + + MockDevice + + + guh + The name of the vendor (2062d64d-3232-433c-88bc-0d33c0ba2ba6) + guh + + + + Mock Device + The name of the deviceClass + Pseudo Gerät + + + + Mock Action 3 (async) + The name of the ActionType fbae06d3-7666-483e-a39e-ec50fe89054e of deviceClass Mock Device + Pseudo Aktion 3 (async) + + + + Mock Action 4 (broken) + The name of the ActionType df3cf33d-26d5-4577-9132-9823bd33fad0 of deviceClass Mock Device + Pseudo Aktion 4 (kaputt) + + + + Mock Action 5 (async, broken) + The name of the ActionType bfe89a1d-3497-4121-8318-e77c37537219 of deviceClass Mock Device + Pseudo Aktion 5 (async, kaputt) + + + + Mock Device (Auto created) + The name of the deviceClass + Pseudo Gerät (Automatisch erstellt) + + + + Mock Device (Push Button) + The name of the deviceClass + Pseudo Gerät (Drückknopf) + + + + Wait 3 second before you continue, the push button will be pressed automatically. + The pairing info of deviceClass Mock Device (Push Button) + Warten Sie 3 Sekunden bevor sie fortfahren, der Knopf wird automatisch für Sie gedrückt. + + + + + Timeout action + The name of the ActionType 54646e7c-bc54-4895-81a2-590d72d120f9 of deviceClass Mock Device (Push Button) +---------- +The name of the ActionType 54646e7c-bc54-4895-81a2-590d72d120f9 of deviceClass Mock Device (Display Pin) + Timeout Aktion + + + + + color + The name of the stateType (20dc7c22-c50e-42db-837c-2bbced939f8e) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (20dc7c22-c50e-42db-837c-2bbced939f8e) of deviceClass Mock Device (Display Pin) + Farbe + + + + + percentage + The name of the stateType (72981c04-267a-4ba0-a59e-9921d2f3af9c) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (72981c04-267a-4ba0-a59e-9921d2f3af9c) of deviceClass Mock Device (Display Pin) + Prozent + + + + + allowed values + The name of the stateType (05f63f9c-f61e-4dcf-ad55-3f13fde2765b) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (05f63f9c-f61e-4dcf-ad55-3f13fde2765b) of deviceClass Mock Device (Display Pin) + Erlaubte Werte + + + + + double value + The name of the stateType (53cd7c55-49b7-441b-b970-9048f20f0e2c) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (53cd7c55-49b7-441b-b970-9048f20f0e2c) of deviceClass Mock Device (Display Pin) + Double Wert + + + + + + + bool value + The name of the stateType (e680f7a4-b39e-46da-be41-fa3170fe3768) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (e680f7a4-b39e-46da-be41-fa3170fe3768) of deviceClass Mock Device (Display Pin) +---------- +The name of the stateType (d24ede5f-4064-4898-bb84-cfb533b1fbc0) of deviceClass Mock Device (Parent) +---------- +The name of the stateType (d24ede5f-4064-4898-bb84-cfb533b1fbc0) of deviceClass Mock Device (Child) + Bool Wert + + + + Mock Device (Display Pin) + The name of the deviceClass + Pseudo Gerät (Pin Anzeigen) + + + + Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681. + The pairing info of deviceClass Mock Device (Display Pin) + Bitte geben sie den Pin ein, der normalerweise auf dem Display des Gerätes angezeigt wird. Für das Pseudo-Gerät lautet der Pin eventType. + + + + Mock Device (Parent) + The name of the deviceClass + Pseudo Gerät (Parent) + + + + Mock Device (Child) + The name of the deviceClass + Pseudo Gerät (Child) + + + + Mock Device (InputTypes) + The name of the deviceClass + Pseudo Gerät (Eingabe Arten) + + + diff --git a/plugins/deviceplugins/mock/translations/mock_en_US.ts b/plugins/deviceplugins/mock/translations/mock_en_US.ts new file mode 100644 index 00000000..d0446da9 --- /dev/null +++ b/plugins/deviceplugins/mock/translations/mock_en_US.ts @@ -0,0 +1,153 @@ + + + + + DevicePluginMock + + + Display pin!! The pin is 243681 + + + + + MockDevice + + + guh + The name of the vendor (2062d64d-3232-433c-88bc-0d33c0ba2ba6) + + + + + Mock Device + The name of the deviceClass + + + + + Mock Action 3 (async) + The name of the ActionType fbae06d3-7666-483e-a39e-ec50fe89054e of deviceClass Mock Device + + + + + Mock Action 4 (broken) + The name of the ActionType df3cf33d-26d5-4577-9132-9823bd33fad0 of deviceClass Mock Device + + + + + Mock Action 5 (async, broken) + The name of the ActionType bfe89a1d-3497-4121-8318-e77c37537219 of deviceClass Mock Device + + + + + Mock Device (Auto created) + The name of the deviceClass + + + + + Mock Device (Push Button) + The name of the deviceClass + + + + + Wait 3 second before you continue, the push button will be pressed automatically. + The pairing info of deviceClass Mock Device (Push Button) + + + + + + Timeout action + The name of the ActionType 54646e7c-bc54-4895-81a2-590d72d120f9 of deviceClass Mock Device (Push Button) +---------- +The name of the ActionType 54646e7c-bc54-4895-81a2-590d72d120f9 of deviceClass Mock Device (Display Pin) + + + + + + color + The name of the stateType (20dc7c22-c50e-42db-837c-2bbced939f8e) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (20dc7c22-c50e-42db-837c-2bbced939f8e) of deviceClass Mock Device (Display Pin) + + + + + + percentage + The name of the stateType (72981c04-267a-4ba0-a59e-9921d2f3af9c) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (72981c04-267a-4ba0-a59e-9921d2f3af9c) of deviceClass Mock Device (Display Pin) + + + + + + allowed values + The name of the stateType (05f63f9c-f61e-4dcf-ad55-3f13fde2765b) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (05f63f9c-f61e-4dcf-ad55-3f13fde2765b) of deviceClass Mock Device (Display Pin) + + + + + + double value + The name of the stateType (53cd7c55-49b7-441b-b970-9048f20f0e2c) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (53cd7c55-49b7-441b-b970-9048f20f0e2c) of deviceClass Mock Device (Display Pin) + + + + + + + + bool value + The name of the stateType (e680f7a4-b39e-46da-be41-fa3170fe3768) of deviceClass Mock Device (Push Button) +---------- +The name of the stateType (e680f7a4-b39e-46da-be41-fa3170fe3768) of deviceClass Mock Device (Display Pin) +---------- +The name of the stateType (d24ede5f-4064-4898-bb84-cfb533b1fbc0) of deviceClass Mock Device (Parent) +---------- +The name of the stateType (d24ede5f-4064-4898-bb84-cfb533b1fbc0) of deviceClass Mock Device (Child) + + + + + Mock Device (Display Pin) + The name of the deviceClass + + + + + Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681. + The pairing info of deviceClass Mock Device (Display Pin) + + + + + Mock Device (Parent) + The name of the deviceClass + + + + + Mock Device (Child) + The name of the deviceClass + + + + + Mock Device (InputTypes) + The name of the deviceClass + + + + diff --git a/plugins/guh-generateplugininfo b/plugins/guh-generateplugininfo index e4a2b001..2b81740e 100755 --- a/plugins/guh-generateplugininfo +++ b/plugins/guh-generateplugininfo @@ -26,46 +26,66 @@ import argparse import traceback import json -import sys +import os +import subprocess __version__="1.0.0" -parser = argparse.ArgumentParser(description='The guh-generateplugininfo is a precompiler for building plugins. This precompiler will create a plugininfo.h containing the uuid definitions from the plugin json file.') -parser.add_argument("input", help="The JSON input file with the plugin description") -parser.add_argument("output", help="The plugininfo.h outputfile file with the uuid declarations") -parser.add_argument('-v','--version', action='version', version=__version__) +# Argument parser +parser = argparse.ArgumentParser(description='The guh-generateplugininfo is a precompiler for building plugins. This precompiler will create a plugininfo.h containing the uuid definitions from the plugin json file and creates the translations for the plugin.') +parser.add_argument('-j', '--jsonfile', help='The JSON input file name with the plugin description', metavar='jsonfile') +parser.add_argument('-b', '--builddir', help='The path to the build directory of the plugin where the plugininfo.h file can be found.', metavar='buildpath') +parser.add_argument('-o', '--output', help='The plugininfo.h outputFile with the uuid declarations', metavar='output') +parser.add_argument('-t', '--translations', help='The translation files for the plugin.', nargs='*', type=str, metavar='*.ts') +parser.add_argument('-v', '--version', action='version', version=__version__) args = parser.parse_args() -inputFile = open(args.input, "r") -outputfile = open(args.output, "w") -outputfile2 = open("extern-" + args.output, "w") +# Get the source directors +sourceDir = os.path.dirname(os.path.abspath(args.jsonfile)) -print "%s -> %s" %(args.input, args.output) +print "Json file: %s" % args.jsonfile +print "Output: %s/%s" % (args.builddir, args.output) +print "Build directory: %s" % args.builddir +print "Source directory: %s" % sourceDir +print "Translations: %s" % args.translations + +# Tuple ('string to translate', 'comment for translater') +translationStrings = [] variableNames = [] externDefinitions = [] + +# Open files +inputFile = open(args.jsonfile, "r") +outputFile = open(args.builddir + "/" + args.output, "w") +outputFileExtern = open(args.builddir + "/" + "extern-" + args.output, "w") + +# Read json file + try: pluginMap = json.loads(inputFile.read()) -except ValueError as e: - print " --> Error loading input file \"%s\"" % (sys.argv[1]) - print " %s" % (e) + inputFile.close() +except ValueError as error: + print " --> Error loading input file \"%s\"" % (args.input) + print " %s" % (error) + inputFile.close() exit -1 +# Methods def writePluginInfo(line): - outputfile.write("%s\n" % line) - + outputFile.write("%s\n" % line) def writeExternPluginInfo(line): - outputfile2.write("%s\n" % line) - + outputFileExtern.write("%s\n" % line) def extractVendors(pluginMap): for vendor in pluginMap['vendors']: try: print("define VendorId %sVendorId = %s" % (pluginMap["idName"], vendor["id"])) writePluginInfo("VendorId %sVendorId = VendorId(\"%s\");" % (vendor["idName"], vendor["id"])) + addTranslationString(vendor['name'], 'The name of the vendor (%s)' % vendor['id']) createExternDefinition("VendorId", "%sVendorId" % (vendor["idName"])) except: pass @@ -75,14 +95,18 @@ def extractVendors(pluginMap): def extractDeviceClasses(vendorMap): for deviceClass in vendorMap["deviceClasses"]: try: - variableName = "%sDeviceClassId" % (deviceClass["idName"]) + variableName = "%sDeviceClassId" % (deviceClass['idName']) + addTranslationString(deviceClass['name'], 'The name of the deviceClass') + if 'pairingInfo' in deviceClass: + addTranslationString(deviceClass['pairingInfo'], 'The pairing info of deviceClass %s' % deviceClass['name']) + if not variableName in variableNames: variableNames.append(variableName) - print("define DeviceClassId %s = %s" % (variableName, deviceClass["deviceClassId"])) - writePluginInfo("DeviceClassId %s = DeviceClassId(\"%s\");" % (variableName, deviceClass["deviceClassId"])) - createExternDefinition("DeviceClassId", variableName) + print('define DeviceClassId %s = %s' % (variableName, deviceClass['deviceClassId'])) + writePluginInfo('DeviceClassId %s = DeviceClassId(\"%s\");' % (variableName, deviceClass['deviceClassId'])) + createExternDefinition('DeviceClassId', variableName) else: - print("duplicated variable name \"%s\" for DeviceClassId %s -> skipping") % (variableName, deviceClass["deviceClassId"]) + print("duplicated variable name \"%s\" for DeviceClassId %s -> skipping") % (variableName, deviceClass['deviceClassId']) except: pass extractActionTypes(deviceClass) @@ -92,9 +116,10 @@ def extractDeviceClasses(vendorMap): def extractStateTypes(deviceClassMap): try: - for stateType in deviceClassMap["stateTypes"]: + for stateType in deviceClassMap['stateTypes']: try: variableName = "%sStateTypeId" % (stateType["idName"]) + addTranslationString(stateType['name'], 'The name of the stateType (%s) of deviceClass %s' % (stateType["id"], deviceClassMap['name'])) if not variableName in variableNames: variableNames.append(variableName) print("define StateTypeId %s = %s" % (variableName, stateType["id"])) @@ -102,6 +127,7 @@ def extractStateTypes(deviceClassMap): createExternDefinition("StateTypeId", variableName) else: print("duplicated variable name \"%s\" for StateTypeId %s -> skipping") % (variableName, stateType["id"]) + # create ActionTypeId if the state is writable if 'writable' in stateType: if stateType['writable']: @@ -124,6 +150,7 @@ def extractActionTypes(deviceClassMap): for actionType in deviceClassMap["actionTypes"]: try: variableName = "%sActionTypeId" % (actionType["idName"]) + addTranslationString(actionType["name"], 'The name of the ActionType %s of deviceClass %s' % (actionType["id"], deviceClassMap['name'])) if not variableName in variableNames: variableNames.append(variableName) writePluginInfo("ActionTypeId %s = ActionTypeId(\"%s\");" % (variableName, actionType["id"])) @@ -141,6 +168,7 @@ def extractEventTypes(deviceClassMap): for eventType in deviceClassMap["eventTypes"]: try: variableName = "%sEventTypeId" % (eventType["idName"]) + addTranslationString(eventType["name"], 'The name of the EventType %s of deviceClass %s' % (eventType["id"], deviceClassMap['name'])) if not variableName in variableNames: variableNames.append(variableName) writePluginInfo("EventTypeId %s = EventTypeId(\"%s\");" % (variableName, eventType["id"])) @@ -152,6 +180,7 @@ def extractEventTypes(deviceClassMap): except: pass + def createExternDefinition(type, name): definition = {} definition['type'] = type @@ -159,10 +188,41 @@ def createExternDefinition(type, name): externDefinitions.append(definition) +def addTranslationString(string, comment): + translationStrings.append([string, comment]) + #translationStrings.append([unicode(string, "utf-8"), unicode(comment, "utf-8")]) + +def writeTranslationStrings(): + if len(args.translations) is 0: + return + + if len(translationStrings) is not 0: + writePluginInfo("// Translation strings") + writePluginInfo("const QString translations[] {") + + for index, value in enumerate(translationStrings): + writePluginInfo(" //: %s" % value[1]) + if index != len(translationStrings) - 1: + writePluginInfo(" QT_TRANSLATE_NOOP(\"%s\", \"%s\"), \n" % (pluginMap["idName"], value[0])) + else: + writePluginInfo(" QT_TRANSLATE_NOOP(\"%s\", \"%s\")" % (pluginMap["idName"], value[0])) + + writePluginInfo("};") + + +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]) + ################################################################################################################## # write plugininfo.h -print " --> generate plugininfo.h" -print "PluginId for plugin \"%s\" = %s" %(pluginMap['name'], pluginMap['id']) + +print " --> generate plugininfo.h for plugin \"%s\" = %s" % (pluginMap['name'], pluginMap['id']) writePluginInfo("/* This file is generated by the guh build system. Any changes to this file will") writePluginInfo(" * be lost.") @@ -173,29 +233,45 @@ writePluginInfo(" */") writePluginInfo("") writePluginInfo("#ifndef PLUGININFO_H") writePluginInfo("#define PLUGININFO_H") -writePluginInfo("#include \"typeutils.h\"") +writePluginInfo("") writePluginInfo("#include ") +writePluginInfo("#include ") +writePluginInfo("") +writePluginInfo("#include \"typeutils.h\"") writePluginInfo("") writePluginInfo("// Id definitions") writePluginInfo("PluginId pluginId = PluginId(\"%s\");" % pluginMap['id']) extractVendors(pluginMap) + writePluginInfo("") writePluginInfo("// Loging category") if 'idName' in pluginMap: - writePluginInfo("Q_DECLARE_LOGGING_CATEGORY(dc%s)" % pluginMap['idName']) - writePluginInfo("Q_LOGGING_CATEGORY(dc%s, \"%s\")" % (pluginMap['idName'], pluginMap['idName'])) - print "define logging category: \"dc%s\"" % pluginMap['idName'] + writePluginInfo('Q_DECLARE_LOGGING_CATEGORY(dc%s)' % pluginMap['idName']) + writePluginInfo('Q_LOGGING_CATEGORY(dc%s, \"%s\")' % (pluginMap['idName'], pluginMap['idName'])) + print 'define logging category: \"dc%s\"' % pluginMap['idName'] writePluginInfo("") -writePluginInfo("#endif // PLUGININFO_H") -print " --> generated successfully \"%s\"" % sys.argv[2] +# Write translation strings +writeTranslationStrings() + +writePluginInfo("") +writePluginInfo("#endif // PLUGININFO_H") +outputFile.close() +print " --> generated successfully \"%s\"" % (args.output) ################################################################################################################## -# write extern-plugininfo.h -print " --> generate extern-plugininfo.h" +# Translate +if len(translationStrings) is not 0: + createTranslationFiles() + +################################################################################################################## +# Write extern-plugininfo.h + +print " --> generate extern-plugininfo.h for plugin \"%s\" = %s" % (pluginMap['name'], pluginMap['id']) + writeExternPluginInfo("/* This file is generated by the guh build system. Any changes to this file will") writeExternPluginInfo(" * be lost.") writeExternPluginInfo(" *") @@ -221,5 +297,8 @@ if 'idName' in pluginMap: writeExternPluginInfo("") writeExternPluginInfo("#endif // EXTERNPLUGININFO_H") +outputFileExtern.close() +print " --> generated successfully \"extern-%s\"" % (args.output) + + -print " --> generated successfully \"extern-%s\"" % (sys.argv[2]) diff --git a/plugins/plugins.pri b/plugins/plugins.pri index 57ede013..c100c157 100644 --- a/plugins/plugins.pri +++ b/plugins/plugins.pri @@ -13,14 +13,24 @@ contains(DEFINES, BLUETOOTH_LE) { INCLUDEPATH += $$top_srcdir/libguh LIBS += -L../../../libguh -lguh +# Create plugininfo file infofile.output = plugininfo.h -infofile.commands = $$top_srcdir/plugins/guh-generateplugininfo ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT} infofile.depends = $$top_srcdir/plugins/guh-generateplugininfo infofile.CONFIG = no_link JSONFILES = deviceplugin"$$TARGET".json infofile.input = JSONFILES +infofile.commands = $$top_srcdir/plugins/guh-generateplugininfo -j ${QMAKE_FILE_NAME} \ + -o ${QMAKE_FILE_OUT} \ + -b $$OUT_PWD \ + -t $$TRANSLATIONS QMAKE_EXTRA_COMPILERS += infofile +# Install translation files +translations.path = /usr/share/guh/translations +translations.files = $$[QT_SOURCE_TREE]/translations/*.qm + +# Install plugin target.path = /usr/lib/guh/plugins/ -INSTALLS += target +INSTALLS += target translations + diff --git a/server/main.cpp b/server/main.cpp index 5d298b1e..c6df0f97 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -24,11 +24,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include "stdio.h" @@ -131,14 +133,15 @@ int main(int argc, char *argv[]) QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); - QString applicationDescription = QString("\nguh ( /[guːh]/ ) is an open source IoT (Internet of Things) server, \n" + QString applicationDescription = QCoreApplication::translate("main", "\nguh ( /[guːh]/ ) is an open source IoT (Internet of Things) server, \n" "which allows to control a lot of different devices from many different \n" "manufacturers. With the powerful rule engine you are able to connect any \n" "device available in the system and create individual scenes and behaviors \n" - "for your environment.\n\n" - "guhd %1 %2 2014-2016 guh GmbH\n" - "Released under the GNU GENERAL PUBLIC LICENSE Version 2.\n\n" - "API version: %3\n").arg(GUH_VERSION_STRING).arg(QChar(0xA9)).arg(JSON_PROTOCOL_VERSION); + "for your environment.\n\n"); + + applicationDescription.append(QString("guhd %1 %2 2014-2016 guh GmbH\n" + "Released under the GNU GENERAL PUBLIC LICENSE Version 2.\n\n" + "API version: %3\n").arg(GUH_VERSION_STRING).arg(QChar(0xA9)).arg(JSON_PROTOCOL_VERSION)); parser.setApplicationDescription(applicationDescription); @@ -162,7 +165,7 @@ int main(int argc, char *argv[]) debugDescription += "\n- " + filterName + " (" + (s_loggingFilters.value(filterName) ? "yes" : "no") + ")"; } - QCommandLineOption allOption(QStringList() << "p" << "print-all", "Enables all debug categories. This parameter overrides all debug category parameters."); + QCommandLineOption allOption(QStringList() << "p" << "print-all", QCoreApplication::translate("main", "Enables all debug categories. This parameter overrides all debug category parameters.")); parser.addOption(allOption); QCommandLineOption debugOption(QStringList() << "d" << "debug-category", debugDescription, "[No]DebugCategory"); parser.addOption(debugOption); @@ -182,7 +185,7 @@ int main(int argc, char *argv[]) if (s_loggingFilters.contains(debugArea)) { s_loggingFilters[debugArea] = enable; } else { - qCWarning(dcApplication) << "No such debug category:" << debugArea; + qCWarning(dcApplication) << QCoreApplication::translate("main", "No such debug category:") << debugArea; } } } else { diff --git a/server/server.pro b/server/server.pro index 6aa03bb1..86ba5de6 100644 --- a/server/server.pro +++ b/server/server.pro @@ -16,7 +16,20 @@ LIBS += -L$$top_builddir/libguh/ -lguh TRANSLATIONS *= $$top_srcdir/translations/guhd_en_US.ts \ $$top_srcdir/translations/guhd_de_DE.ts -include(../translations.pri) +# Update ts files and create translation qm files +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; + +QMAKE_EXTRA_COMPILERS += lrelease +PRE_TARGETDEPS += compiler_lrelease_make_all + +# Install translation files +translations.path = /usr/share/guh/translations +translations.files = $$[QT_SOURCE_TREE]/translations/*.qm +INSTALLS += translations # Server files include(server.pri) diff --git a/tests/auto/api.json b/tests/auto/api.json index bb0d6f28..5f3b3858 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -68,12 +68,23 @@ "enabled": "Bool" } }, + "Configuration.GetAvailableLanguages": { + "description": "Returns a list of locale codes available for the server. i.e. en_US, de_AT", + "params": { + }, + "returns": { + "languages": [ + "String" + ] + } + }, "Configuration.GetConfigurations": { "description": "Get all configuration parameters of the server.", "params": { }, "returns": { "basicConfiguration": { + "language": "String", "serverName": "String", "serverTime": "Uint", "serverUuid": "Uuid", @@ -106,6 +117,15 @@ ] } }, + "Configuration.SetLanguage": { + "description": "Sets the server language to the given language. See also: \"GetAvailableLanguages\"", + "params": { + "language": "String" + }, + "returns": { + "configurationError": "$ref:ConfigurationError" + } + }, "Configuration.SetServerName": { "description": "Set the name of the server. Default is guhIO.", "params": { diff --git a/translations.pri b/translations.pri index b2975f05..9011df0f 100644 --- a/translations.pri +++ b/translations.pri @@ -1,17 +1,3 @@ include(guh.pri) -# Create translation files -lrelease.input = TRANSLATIONS -lrelease.output = $$top_srcdir/${QMAKE_FILE_BASE}.qm -lrelease.commands = $$[QT_INSTALL_BINS]/lupdate ${QMAKE_FILE_IN} -ts $$TRANSLATIONS; $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm -lrelease.CONFIG += no_link -QMAKE_EXTRA_COMPILERS += lrelease -PRE_TARGETDEPS += compiler_lrelease_make_all - -message("Translations:" $$TRANSLATIONS ) - -translations.path = /usr/share/guh/translations -translations.files = $$[QT_SOURCE_TREE]/translations/*.qm - -INSTALLS += translations diff --git a/translations/guhd_de_DE.ts b/translations/guhd_de_DE.ts index c26e3ba7..1d0db88d 100644 --- a/translations/guhd_de_DE.ts +++ b/translations/guhd_de_DE.ts @@ -4,17 +4,46 @@ main - - Run guhd in the foreground, not as daemon. - Starte guhd im Vordergrund, nicht als service. + + +guh ( /[guːh]/ ) 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 +device available in the system and create individual scenes and behaviors +for your environment. + + + +guh ( /[guːh]/ ) ist ein Opensource IoT (Internet der Dinge) Server, +der es ermöglicht viele verschiedene Geräte von unterschiedlichen +Herstellern anzusteuern. Durch das eingebaute Regelwerk wird es ermöglicht, +die im System verfügbaren Geräte miteinander zu verbinden und individuelle +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: - Zu aktivierende Debug-Kategorien. Kategorien mit dem Präfix "No" werden deaktiviert. Warnungen werden von allen Kategorien ausgegeben außer sie wurden explizit mit dem Prefix "NoWarnings" deaktiviert. -Kategorien sind: + Zu aktivierende Debug-Kategorien. Kategorien mit dem Präfix "No" werden deaktiviert. Warnungen werden von allen Kategorien angezeigt außer sie wurden explizit mit dem Prefix "NoWarnings" deaktiviert. +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 558e5d3e..4b55ebeb 100644 --- a/translations/guhd_en_US.ts +++ b/translations/guhd_en_US.ts @@ -4,16 +4,38 @@ main - - Run guhd in the foreground, not as daemon. + + +guh ( /[guːh]/ ) 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 +device available in the system and create individual scenes and behaviors +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: + +