I want to generate a plenty *.qm
for plenty *.ts
files for different languages using qt5_add_translation
. All the *.ts
files are named using *.de_DE.ts
/*.fr_FR.ts
/etc convention. But qt5_add_translation
produce output, using only basename until first .
, not the last one.
There is no possibility to pass options to lrelease
using qt5_add_translation(QM_FILES "${PROJECT_NAME}.de_DE.ts" OPTIONS -qm "${PROJECT_NAME}.de_DE.qm")
syntax.
Also setting OUTPUT_NAME
property for source *.ts
file is not working:
set_source_files_properties(
"${PROJECT_NAME}.de_DE.ts" PROPERTIES
OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_NAME "${PROJECT_NAME}.de_DE.qm"
)
Producing filename in the case is still "${PROJECT_NAME}.qm"
, not "${PROJECT_NAME}.de_DE.qm"
How to override producing name for resulting *.qm
file?
Surely I can make custom command and use it for my purposes, but I prefer to use ready qt5_add_translation
.
EDIT:
Looking at /usr/local/Qt-5.9.2/lib/cmake/Qt5LinguistTools/Qt5LinguistToolsMacros.cmake
I conclude, that there is no way to achieve desired using ready to use qt5_add_translation
, because of using get_filename_component(qm ${_abs_FILE} NAME_WE)
to get filename:
NAME_WE = File name without directory or longest extension
For my purposes there is need to use combination of ABSOLUTE
(to get filename w/ full suffix), then to apply multiple times EXT
in combination with NAME_WE
to extract filename w/o shortest extension.
I ended up with the below custom function
add_translation
to replaceqt5_add_translation
:It accepts basenames of
*.ts
files and produces list of resulting*.qm
files: both in current source directory.