diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2024-01-25 16:37:46 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2024-01-26 17:27:37 +0100 |
commit | 3f34ef350dc09043714201ae6ad2f7265de3b12a (patch) | |
tree | 68fed1b0fd515b5824a130474ee6ec9420b6b0e7 | |
parent | 51a08cc79e0a6dffebef83b5ac8936826fca7db9 (diff) |
CMake: Don't pass .qm files to lupdate
If a target has .qm files in its sources, we passed those .qm files to
lupdate as input. Lupdate then transfers the translations in the .qm
files to the .ts files, which leads to translations that don't have
corresponding source lines.
We now filter out .qm files from lupdate's input. As drive-by, we also
filter out all .json files which don't contribute to i18n.
Pick-to: 6.5
Fixes: QTBUG-118808
Change-Id: I06563c0029dd50811dd0a04b04eb63d660e44eb2
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Otto Ryynänen <otto.ryynanen@qt.io>
(cherry picked from commit 666e7ad35a83c85bcbb531ea01d2257ebea2bdfe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 4659b576ae67f97d0bdd48d209298b35f5e315ed)
-rw-r--r-- | src/linguist/GenerateLUpdateProject.cmake | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/linguist/GenerateLUpdateProject.cmake b/src/linguist/GenerateLUpdateProject.cmake index 2c6b03d10..fb15333c0 100644 --- a/src/linguist/GenerateLUpdateProject.cmake +++ b/src/linguist/GenerateLUpdateProject.cmake @@ -42,6 +42,15 @@ function(filter_generated_ui_headers out_var) set("${out_var}" "${result}" PARENT_SCOPE) endfunction() +# Remove source files that are unsuitable input for lupdate. +# filter_unsuitable_lupdate_input(sources main.cpp foo_de.qm bar.qml whatever_metatypes.json) +# -> main.cpp bar.qml +function(filter_unsuitable_lupdate_input out_var) + set(result ${ARGN}) + list(FILTER result EXCLUDE REGEX "\\.(qm|json)$") + set("${out_var}" "${result}" PARENT_SCOPE) +endfunction() + get_filename_component(project_root "${lupdate_project_file}" DIRECTORY) # Make relative paths absolute to the project root @@ -64,6 +73,7 @@ foreach(path IN LISTS absolute_sources) endforeach() filter_generated_ui_headers(sources ${existing_sources}) +filter_unsuitable_lupdate_input(sources ${sources}) list_to_json_array("${sources}" json_sources) list_to_json_array("${absolute_include_paths}" json_include_paths) |