Qt internationalization and CMake: how to update *.ts and don't lose them -
i'm having cmakelists.txt
in directory translation files (*.ts
):
set(translations lang_de.ts lang_en.ts ) find_package(qt5linguisttools) qt5_add_translation(qm_files ${translations}) set(qm_files ${qm_files} parent_scope) add_custom_target (translations depends ${qm_files})
it builds *.qm
files specified *.ts
.
but want improve , 2 custom targets, won't built automatically. 1 appending new strings sources ts
files, , 1 refreshing ts
. last 1 update ts
sources , remove obsolete strings ts
.
i've tried add after lines above:
add_custom_target ( ts_append command qt5_create_translation(qm_files ${cmake_source_dir}/src/app ${translations} options -i ${cmake_source_dir}/src) ) add_custom_target ( ts_refresh command qt5_create_translation(qm_files ${cmake_source_dir}/src/app ${translations} options -no-obsolete -i ${cmake_source_dir}/src) )
but seems can't use qt5_create_translation
macro inside custom target, isn't it?
maybe i'm on wrong way, how solve problem: easy updating of ts
, don't lose them after make clean
?
to solve make clean
problem, add sub directory (add_subdirectory(translations)
) , add set_directory_properties(properties clean_no_custom 1)
contained cmakelists.txt. see here example of that.
for second part of question there 2 possible ways it. either use file(write <filename> "qt5_create_translation(qm_files ${source_dir}/src/app ${translations} options -i ${source_dir}/src)")
, use command ${cmake_command} -dsource_dir=${cmake_source_dir} -dtranslations=${translations} <filename>
in add_custom_target. doubt there's way of retrieving contents of qm_files though. second option creating 2 additional sub directories, each qt5_create_translations , add_custom_target call.
Comments
Post a Comment