qt5base-lts/mkspecs/features/lrelease.prf
Joerg Bornemann 5678ee93b4 Fix .qm file name calculation in lrelease.prf
The following snippet in a .pro file resulted in a build error:

  CONFIG += lrelease embed_translations
  TRANSLATIONS += foo.bar_de.ts

The variable QM_FILES was incorrectly calculated.  The extra compiler
that calls lrelease uses QMAKE_FILE_IN_BASE, which wraps
QFileInfo::completeBaseName(), resulting in "foo.bar_de.qm".

The $$replace call that calculates the .qm file name however, produces
"foo.qm".

Fix this mismatch by adjusting the regular expression to behave like
QFileInfo::completeBaseName().

Pick-to: 5.15 6.2
Fixes: QTBUG-79016
Change-Id: I545d1b58170cd5229007faf31c9b2c6f70ff75a6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-09-10 23:27:15 +02:00

43 lines
1.6 KiB
Plaintext

# 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
qm_files.CONFIG = no_check_exist
INSTALLS += qm_files
}
lrelease.CONFIG += target_predeps no_clean
}