add translations mechanism for plugins

pull/135/head
Simon Stürz 2016-07-27 11:31:42 +02:00 committed by Michael Zanetti
parent 3db2fe81d6
commit 1e4e2ac09c
17 changed files with 544 additions and 71 deletions

1
debian/changelog vendored
View File

@ -1,5 +1,6 @@
guh (0.7.6) xenial; urgency=medium
* Add translations
* Add bluetooth server
-- Simon Stürz <simon.stuerz@guh.guru> Wed, 14 Sep 2016 15:43:22 +0200

View File

@ -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.

View File

@ -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",

View File

@ -1,4 +1,5 @@
include (../../plugins.pri)
TARGET = $$qtLibraryTarget(guh_deviceplugincommandlauncher)
SOURCES += \

View File

@ -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;
}

View File

@ -1,6 +1,7 @@
{
"name": "Mock Devices",
"idName": "MockDevice",
"translationPrefix": "mock",
"id": "727a4a9a-c187-446f-aadf-f1b2220607d1",
"paramTypes": [
{

View File

@ -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

View File

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
<name>DevicePluginMock</name>
<message>
<location filename="../devicepluginmock.cpp" line="214"/>
<source>Display pin!! The pin is 243681</source>
<translation>Pin anzeigen!! Der pin lautet 243581</translation>
</message>
</context>
<context>
<name>MockDevice</name>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="50"/>
<source>guh</source>
<extracomment>The name of the vendor (2062d64d-3232-433c-88bc-0d33c0ba2ba6)</extracomment>
<translation>guh</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="53"/>
<source>Mock Device</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="56"/>
<source>Mock Action 3 (async)</source>
<extracomment>The name of the ActionType fbae06d3-7666-483e-a39e-ec50fe89054e of deviceClass Mock Device</extracomment>
<translation>Pseudo Aktion 3 (async)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="59"/>
<source>Mock Action 4 (broken)</source>
<extracomment>The name of the ActionType df3cf33d-26d5-4577-9132-9823bd33fad0 of deviceClass Mock Device</extracomment>
<translation>Pseudo Aktion 4 (kaputt)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="62"/>
<source>Mock Action 5 (async, broken)</source>
<extracomment>The name of the ActionType bfe89a1d-3497-4121-8318-e77c37537219 of deviceClass Mock Device</extracomment>
<translation>Pseudo Aktion 5 (async, kaputt)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="65"/>
<source>Mock Device (Auto created)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät (Automatisch erstellt)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="68"/>
<source>Mock Device (Push Button)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät (Drückknopf)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="71"/>
<source>Wait 3 second before you continue, the push button will be pressed automatically.</source>
<extracomment>The pairing info of deviceClass Mock Device (Push Button)</extracomment>
<translation>Warten Sie 3 Sekunden bevor sie fortfahren, der Knopf wird automatisch für Sie gedrückt.</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="74"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="98"/>
<source>Timeout action</source>
<extracomment>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)</extracomment>
<translation>Timeout Aktion</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="77"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="101"/>
<source>color</source>
<extracomment>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)</extracomment>
<translation>Farbe</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="80"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="104"/>
<source>percentage</source>
<extracomment>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)</extracomment>
<translation>Prozent</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="83"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="107"/>
<source>allowed values</source>
<extracomment>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)</extracomment>
<translation>Erlaubte Werte</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="86"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="110"/>
<source>double value</source>
<extracomment>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)</extracomment>
<translation>Double Wert</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="89"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="113"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="119"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="125"/>
<source>bool value</source>
<extracomment>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)</extracomment>
<translation>Bool Wert</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="92"/>
<source>Mock Device (Display Pin)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät (Pin Anzeigen)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="95"/>
<source>Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681.</source>
<extracomment>The pairing info of deviceClass Mock Device (Display Pin)</extracomment>
<translation>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.</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="116"/>
<source>Mock Device (Parent)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät (Parent)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="122"/>
<source>Mock Device (Child)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät (Child)</translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="128"/>
<source>Mock Device (InputTypes)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation>Pseudo Gerät (Eingabe Arten)</translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>DevicePluginMock</name>
<message>
<location filename="../devicepluginmock.cpp" line="214"/>
<source>Display pin!! The pin is 243681</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MockDevice</name>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="50"/>
<source>guh</source>
<extracomment>The name of the vendor (2062d64d-3232-433c-88bc-0d33c0ba2ba6)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="53"/>
<source>Mock Device</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="56"/>
<source>Mock Action 3 (async)</source>
<extracomment>The name of the ActionType fbae06d3-7666-483e-a39e-ec50fe89054e of deviceClass Mock Device</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="59"/>
<source>Mock Action 4 (broken)</source>
<extracomment>The name of the ActionType df3cf33d-26d5-4577-9132-9823bd33fad0 of deviceClass Mock Device</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="62"/>
<source>Mock Action 5 (async, broken)</source>
<extracomment>The name of the ActionType bfe89a1d-3497-4121-8318-e77c37537219 of deviceClass Mock Device</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="65"/>
<source>Mock Device (Auto created)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="68"/>
<source>Mock Device (Push Button)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="71"/>
<source>Wait 3 second before you continue, the push button will be pressed automatically.</source>
<extracomment>The pairing info of deviceClass Mock Device (Push Button)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="74"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="98"/>
<source>Timeout action</source>
<extracomment>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)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="77"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="101"/>
<source>color</source>
<extracomment>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)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="80"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="104"/>
<source>percentage</source>
<extracomment>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)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="83"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="107"/>
<source>allowed values</source>
<extracomment>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)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="86"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="110"/>
<source>double value</source>
<extracomment>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)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="89"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="113"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="119"/>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="125"/>
<source>bool value</source>
<extracomment>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)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="92"/>
<source>Mock Device (Display Pin)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="95"/>
<source>Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681.</source>
<extracomment>The pairing info of deviceClass Mock Device (Display Pin)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="116"/>
<source>Mock Device (Parent)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="122"/>
<source>Mock Device (Child)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/mock/plugininfo.h" line="128"/>
<source>Mock Device (InputTypes)</source>
<extracomment>The name of the deviceClass</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -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 <QLoggingCategory>")
writePluginInfo("#include <QObject>")
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])

View File

@ -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

View File

@ -24,11 +24,13 @@
#include <QCoreApplication>
#include <QLoggingCategory>
#include <QMessageLogger>
#include <QTranslator>
#include <QStringList>
#include <QTextStream>
#include <QDateTime>
#include <QtPlugin>
#include <QtDebug>
#include <QString>
#include <QFile>
#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 {

View File

@ -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)

View File

@ -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": {

View File

@ -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

View File

@ -4,17 +4,46 @@
<context>
<name>main</name>
<message>
<location filename="../server/main.cpp" line="145"/>
<source>Run guhd in the foreground, not as daemon.</source>
<translation>Starte guhd im Vordergrund, nicht als service.</translation>
<location filename="../server/main.cpp" line="136"/>
<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
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.
</source>
<translation>
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.
</translation>
</message>
<message>
<location filename="../server/main.cpp" line="148"/>
<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"/>
<source>Debug categories to enable. Prefix with &quot;No&quot; to disable. Warnings from all categories will be printed unless explicitly muted with &quot;NoWarnings&quot;.
Categories are:</source>
<translation>Zu aktivierende Debug-Kategorien. Kategorien mit dem Präfix &quot;No&quot; werden deaktiviert. Warnungen werden von allen Kategorien ausgegeben außer sie wurden explizit mit dem Prefix &quot;NoWarnings&quot; deaktiviert.
Kategorien sind:</translation>
<translation>Zu aktivierende Debug-Kategorien. Kategorien mit dem Präfix &quot;No&quot; werden deaktiviert. Warnungen werden von allen Kategorien angezeigt außer sie wurden explizit mit dem Prefix &quot;NoWarnings&quot; deaktiviert.
Es gibt folgende Kategorien:</translation>
</message>
<message>
<location filename="../server/main.cpp" line="168"/>
<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"/>
<source>No such debug category:</source>
<translation>Diese Debug-Kategorie existiert nicht:</translation>
</message>
</context>
</TS>

View File

@ -4,16 +4,38 @@
<context>
<name>main</name>
<message>
<location filename="../server/main.cpp" line="145"/>
<source>Run guhd in the foreground, not as daemon.</source>
<location filename="../server/main.cpp" line="136"/>
<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
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.
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../server/main.cpp" line="148"/>
<source>Run guhd in the foreground, not as daemon.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../server/main.cpp" line="151"/>
<source>Debug categories to enable. Prefix with &quot;No&quot; to disable. Warnings from all categories will be printed unless explicitly muted with &quot;NoWarnings&quot;.
Categories are:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../server/main.cpp" line="168"/>
<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"/>
<source>No such debug category:</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>