summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucie GĂ©rard <lucie.gerard@qt.io>2021-09-07 16:44:23 +0200
committerLucie Gerard <lucie.gerard@qt.io>2021-10-05 09:30:00 +0000
commit5cf27fb76e006a4555af48753e3dab2973af2547 (patch)
tree77da1e48148894519cffd6cc0c74b87ff8bef0c3
parent3318504088253257c26b07aaf8f0a9d153dcbace (diff)
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. Pick-to: 6.2 Change-Id: I051761ad916af3affdd70e57e77cc245fd399de1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-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>