diff --git a/common.pri b/common.pri index a57246b..2e7bf18 100644 --- a/common.pri +++ b/common.pri @@ -1,3 +1,4 @@ +#CONFIG += build_translations CONFIG += zint ZINT_PATH = $$PWD/3rdparty/zint-2.4.4 @@ -11,6 +12,7 @@ DEFINES += LIMEREPORT_VERSION=$${LIMEREPORT_VERSION} QT += script xml sql REPORT_PATH = $$PWD/limereport +TRANSLATIONS_PATH = $$PWD/translations greaterThan(QT_MAJOR_VERSION, 4) { DEFINES+=HAVE_QT5 diff --git a/limereport/limereport.pro b/limereport/limereport.pro index 4f6dafe..c422868 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -70,28 +70,33 @@ contains(CONFIG,zint){ ####### ####Automatically build required translation files (*.qm) +contains(CONFIG,build_translations){ + LANGUAGES = ru es_ES -LANGUAGES = ru es_ES + defineReplace(prependAll) { + for(a,$$1):result += $$2$${a}$$3 + return($$result) + } -defineReplace(prependAll) { - for(a,$$1):result += $$2$${a}$$3 - return($$result) + TRANSLATIONS = $$prependAll(LANGUAGES, $$TRANSLATIONS_PATH/limereport_,.ts) + qtPrepareTool(LUPDATE, lupdate) + ts.commands = $$LUPDATE $$PWD -ts $$TRANSLATIONS + + TRANSLATIONS_FILES = + qtPrepareTool(LRELEASE, lrelease) + for(tsfile, TRANSLATIONS) { + qmfile = $$tsfile + qmfile ~= s,.ts$,.qm, + qm.commands += $$LRELEASE -removeidentical $$tsfile -qm $$qmfile $$escape_expand(\\n\\t) + tmp_command = $$LRELEASE -removeidentical $$tsfile -qm $$qmfile $$escape_expand(\\n\\t) + TRANSLATIONS_FILES += $$qmfile + } + qm.depends = ts + + QMAKE_EXTRA_TARGETS += qm ts + POST_TARGETDEPS += qm } -TRANSLATIONS_PATH = $$PWD/../translations -TRANSLATIONS = $$prependAll(LANGUAGES, $$TRANSLATIONS_PATH/limereport_,.ts) - -qtPrepareTool(LUPDATE, lupdate) -ts.commands = $$LUPDATE $$_PRO_FILE_ - -qtPrepareTool(LRELEASE, lrelease) -qm.commands = $$LRELEASE $$_PRO_FILE_ -qm.depends = ts - -QMAKE_EXTRA_TARGETS += qm ts -POST_TARGETDEPS += qm ts - - #### EN AUTOMATIC TRANSLATIONS