summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucie GĂ©rard <lucie.gerard@qt.io>2021-09-07 16:44:23 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-05 12:31:53 +0000
commite9ca81df66d45504441ee2d3d36672043dbbe82f (patch)
tree62e450c944cbbd7555ed5a4e225165798c03bd97
parentb107ee4f9fbce8db4d26d3c98062778f346d3ad6 (diff)
downloadqttools-e9ca81df66d45504441ee2d3d36672043dbbe82f.tar.gz
lupdate: Default to absolute locations for message-less .ts files
If the .ts file that is to be handled by the CMake command qt6_add_lrelease does not exist yet, the function creates an initial file, which can be used by lupdate as base line. This file is devoid of any messages and the subsequent .ts file will have no locations. Fix that by changing the default of message-less .ts files to absolute. For new files, lupdate already defaulted to absolute locations. Doing that for .ts files without messages seems just consistent. Change-Id: I051761ad916af3affdd70e57e77cc245fd399de1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 5cf27fb76e006a4555af48753e3dab2973af2547) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/linguist/shared/ts.cpp3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp
index a5daf7c90..3cf5f1d31 100644
--- a/src/linguist/shared/ts.cpp
+++ b/src/linguist/shared/ts.cpp
@@ -412,6 +412,9 @@ bool TSReader::read(Translator &translator)
} else {
handleError();
}
+ // if the file is empty adopt AbsoluteLocation (default location type for Translator)
+ if (translator.messageCount() == 0)
+ maybeAbsolute = true;
translator.setLocationsType(maybeRelative ? Translator::RelativeLocations :
maybeAbsolute ? Translator::AbsoluteLocations :
Translator::NoLocations);
diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result
index 51a15683d..2bd6d92f9 100644
--- a/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result
@@ -4,10 +4,12 @@
<context>
<name>FindDialog</name>
<message>
+ <location filename="project.ui" line="42"/>
<source>Qt Assistant - Finn text</source>
<translation></translation>
</message>
<message>
+ <location filename="project.ui" line="45"/>
<source>Finn tekst</source>
<translation type="unfinished"></translation>
</message>