diff options
author | Eike Ziller <eike.ziller@qt.io> | 2022-11-02 10:14:19 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2022-11-09 11:11:13 +0000 |
commit | 872994b5e5c15a5fc069b50cb2d5e1567aa1f7b7 (patch) | |
tree | 7134c7a85dea10b5aa226ec5a8b8b5ea6dd0b0ec | |
parent | c406df7470a4c88861367d0bf6e6be34a1179611 (diff) | |
download | qt-creator-872994b5e5c15a5fc069b50cb2d5e1567aa1f7b7.tar.gz |
CMake/translations: Use lconvert for cleaning ts files
For the translation process it is nice to keep obsolete items and locations,
but we do not want these submitted in the end. So while translating we'd have
patches:
1. lupdate cleaned of obsolete and line numbers
2. wip: lupdate with obsolete and line numbers
3. translation of plugin X
4. translation of plugin Y
and before submitting we want to remove the wip patch (2).
But, running lupdate with "-no-obsolete -locations none" for cleaning
the ts file has a slightly different sorting than without it, which
leads to conflicts when removing the wip patch (2).
Instead run lupdate with obsolete items and line numbers first, and
clean the ts file with lconvert afterwards. That keeps the diff between
patch (1) and (2) minimal, and results in a clean rebase process when
removing patch (2).
Change-Id: I3b8ac7c30dc6eb0e501be765eb6e64069007a5bd
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | cmake/QtCreatorTranslations.cmake | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/cmake/QtCreatorTranslations.cmake b/cmake/QtCreatorTranslations.cmake index cd50d72f10..2fb3f79982 100644 --- a/cmake/QtCreatorTranslations.cmake +++ b/cmake/QtCreatorTranslations.cmake @@ -97,12 +97,23 @@ function(_create_ts_custom_target name) DEPENDS ${_sources} VERBATIM) - add_custom_target("${_arg_TS_TARGET_PREFIX}${name}_cleaned" - COMMAND Qt5::lupdate -locations relative -no-ui-lines -no-sort -no-obsolete -locations none "@${ts_file_list}" -ts ${ts_files} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "Generate .ts files, remove obsolete and vanished translations, and do not add files and line number" - DEPENDS ${_sources} - VERBATIM) + # Add cleaned target only for single-ts targets + # Uses lupdate + convert instead of just lupdate with '-locations none -no-obsolete' + # to keep the same sorting as the non-'cleaned' target and therefore keep the diff small + list(LENGTH ts_files file_count) + if(file_count EQUAL 1) + # get path for lconvert... + get_target_property(_lupdate_binary Qt5::lupdate IMPORTED_LOCATION) + get_filename_component(_bin_dir ${_lupdate_binary} DIRECTORY) + + add_custom_target("${_arg_TS_TARGET_PREFIX}${name}_cleaned" + COMMAND Qt5::lupdate -locations relative -no-ui-lines -no-sort "@${ts_file_list}" -ts ${ts_files} + COMMAND ${_bin_dir}/lconvert -locations none -no-ui-lines -no-obsolete ${ts_files} -o ${ts_files} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Generate .ts files, remove obsolete and vanished translations, and do not add files and line number" + DEPENDS ${_sources} + VERBATIM) + endif() endfunction() function(add_translation_targets file_prefix) |