diff options
author | Kai Koehne <kai.koehne@qt.io> | 2018-07-17 17:57:55 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2018-07-28 14:43:28 +0000 |
commit | 01d2f35b6988edacc741b358703d16d4cd8c199a (patch) | |
tree | 9d798c6830959e2d2f1778044a1d55e59e99e63b /mkspecs | |
parent | 128a6eec065dfe683e6d776183d63908ca02e8fb (diff) |
qmake: Add support for running lrelease
CONFIG+=lrelease enables that all .ts files in
TRANSLATIONS or EXTRA_TRANSLATIONS are compiled by
lrelease.
EXTRA_TRANSLATIONS is a new variable that is only
processed by lrelease, but not lupdate - this
is useful for translation files that are supposed to
be empty, because they match the language of the
original translation sources.
If embed_translations is also set, the generated .qm
files will be made available through the Qt resource
system under :/i18n/. Alternatively, the user can
specify an installation target by setting
QM_FILES_INSTALL_PATH.
Note that relative paths in TRANSLATIONS are not taken
into account. That is,
TRANSLATIONS = component1/de.ts component2/de.ts
will cause a conflict.
[ChangeLog][qmake] New CONFIG options lrelease and
embed_translations were added. CONFIG+=lrelease does
run lrelease on translation files listed in TRANSLATIONS
and EXTRA_TRANSLATIONS. CONFIG+=embed_translations does
include the generated .qm files as resources under
:/i18n/.
Change-Id: I94db5b8431d07b24f59b2c332ede91450f9c0c58
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'mkspecs')
-rw-r--r-- | mkspecs/features/exclusive_builds.prf | 4 | ||||
-rw-r--r-- | mkspecs/features/lrelease.prf | 41 | ||||
-rw-r--r-- | mkspecs/features/qt_build_config.prf | 1 |
3 files changed, 44 insertions, 2 deletions
diff --git a/mkspecs/features/exclusive_builds.prf b/mkspecs/features/exclusive_builds.prf index 2d7f0e1ab6..1ff9a04d42 100644 --- a/mkspecs/features/exclusive_builds.prf +++ b/mkspecs/features/exclusive_builds.prf @@ -38,5 +38,5 @@ defineTest(addExclusiveBuilds) { } # Default directories to process -QMAKE_DIR_REPLACE = OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR QGLTF_DIR DESTDIR TRACEGEN_DIR QMLCACHE_DIR -QMAKE_DIR_REPLACE_SANE += QGLTF_DIR TRACEGEN_DIR QMLCACHE_DIR +QMAKE_DIR_REPLACE = OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR QGLTF_DIR DESTDIR TRACEGEN_DIR QMLCACHE_DIR LRELEASE_DIR +QMAKE_DIR_REPLACE_SANE += QGLTF_DIR TRACEGEN_DIR QMLCACHE_DIR LRELEASE_DIR diff --git a/mkspecs/features/lrelease.prf b/mkspecs/features/lrelease.prf new file mode 100644 index 0000000000..1e828b64df --- /dev/null +++ b/mkspecs/features/lrelease.prf @@ -0,0 +1,41 @@ +# Automatically generate .qm files out of .ts files in TRANSLATIONS and +# EXTRA_TRANSLATIONS. +# +# If embed_translations is enabled, the generated .qm files are made available +# in the resource system under :/i18n/. +# +# Otherwise, the .qm files are available in the build directory in LRELEASE_DIR. +# They can also be automatically installed by setting QM_FILES_INSTALL_PATH. + +qtPrepareTool(QMAKE_LRELEASE, lrelease) + +isEmpty(LRELEASE_DIR): LRELEASE_DIR = .qm +isEmpty(QM_FILES_RESOURCE_PREFIX): QM_FILES_RESOURCE_PREFIX = i18n + +lrelease.name = lrelease +lrelease.input = TRANSLATIONS EXTRA_TRANSLATIONS +lrelease.output = $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm +lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} $$QMAKE_LRELEASE_FLAGS -qm ${QMAKE_FILE_OUT} +silent: lrelease.commands = @echo lrelease ${QMAKE_FILE_IN} && $$lrelease.commands +lrelease.CONFIG = no_link +QMAKE_EXTRA_COMPILERS += lrelease + +all_translations = $$TRANSLATIONS $$EXTRA_TRANSLATIONS +for (translation, all_translations) { + # mirrors $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm above + translation = $$basename(translation) + QM_FILES += $$OUT_PWD/$$LRELEASE_DIR/$$replace(translation, \\..*$, .qm) +} +embed_translations { + qmake_qm_files.files = $$QM_FILES + qmake_qm_files.base = $$OUT_PWD/$$LRELEASE_DIR + qmake_qm_files.prefix = $$QM_FILES_RESOURCE_PREFIX + RESOURCES += qmake_qm_files +} else { + !isEmpty(QM_FILES_INSTALL_PATH) { + qm_files.files = $$QM_FILES + qm_files.path = $$QM_FILES_INSTALL_PATH + INSTALLS += qm_files + } + lrelease.CONFIG += target_predeps no_clean +} diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf index 021036e4f9..0c6c10dded 100644 --- a/mkspecs/features/qt_build_config.prf +++ b/mkspecs/features/qt_build_config.prf @@ -27,6 +27,7 @@ RCC_DIR = .rcc UI_DIR = .uic TRACEGEN_DIR = .tracegen QMLCACHE_DIR = .qmlcache +LRELEASE_DIR = .qm intel_icl { # ICL 14.0 has a bug that makes it not find #includes in dirs starting with . MOC_DIR = tmp/moc |