diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-09-06 17:28:41 +0200 |
---|---|---|
committer | Lucie GĂ©rard <lucie.gerard@qt.io> | 2021-09-09 07:56:12 +0200 |
commit | 71913bc2367999525825247291f80e2d3461c8c0 (patch) | |
tree | 6f55df70235067c1787031abde4863b2b1ca2d63 /src/linguist | |
parent | 297ca0610b71326b31bacb06e04cd78e8bfea37b (diff) | |
download | qttools-71913bc2367999525825247291f80e2d3461c8c0.tar.gz |
qt6_add_lrelease: Generate initial .ts files with target language
If the .ts file that is to be handled by qt6_add_lrelease does not exist
yet, the function creates an initial file, which can be used by lupdate
as base line.
However, the initial file did not have a target language set, and it
will never be set by subsequent lupdate calls.
Add a custom command that provides the initial .ts file by calling
"lupdate -ts <filename>", which guesses the target language from the
file name.
Pick-to: 6.2
Change-Id: Id878b1197673f286e1d16fb191e08821e7b81ae5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/linguist')
-rw-r--r-- | src/linguist/Qt6LinguistToolsMacros.cmake | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/linguist/Qt6LinguistToolsMacros.cmake b/src/linguist/Qt6LinguistToolsMacros.cmake index be20b3464..4bfd5c48a 100644 --- a/src/linguist/Qt6LinguistToolsMacros.cmake +++ b/src/linguist/Qt6LinguistToolsMacros.cmake @@ -215,16 +215,15 @@ function(qt6_add_lrelease target) set(qm_files "") foreach(ts_file ${ts_files}) if(NOT EXISTS "${ts_file}") - # Write an empty .ts file that can be read by lrelease and updated by lupdate. message(WARNING "Translation file '${ts_file}' does not exist. " "Consider building the target '${target}_lupdate' to create an initial " "version of that file.") - file(WRITE "${ts_file}" - [[<?xml version="1.0" encoding="utf-8"?> - <!DOCTYPE TS> - <TS version="2.1"> - </TS> - ]]) + + # Provide a command that creates an initial .ts file with the right language set. + # The language is guessed by lupdate from the file name. + add_custom_command(OUTPUT ${ts_file} + COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::lupdate -ts ${ts_file} + VERBATIM) endif() get_filename_component(qm ${ts_file} NAME_WLE) string(APPEND qm ".qm") |