From 3f34ef350dc09043714201ae6ad2f7265de3b12a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 25 Jan 2024 16:37:46 +0100 Subject: CMake: Don't pass .qm files to lupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Otto Ryynänen (cherry picked from commit 666e7ad35a83c85bcbb531ea01d2257ebea2bdfe) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 4659b576ae67f97d0bdd48d209298b35f5e315ed) --- src/linguist/GenerateLUpdateProject.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- cgit v1.2.3