Skip to content

Commit

Permalink
CMake/translations: Use lconvert for cleaning ts files
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: <[email protected]>
  • Loading branch information
e4z9 committed Nov 9, 2022
1 parent c406df7 commit 872994b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions cmake/QtCreatorTranslations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 872994b

Please sign in to comment.