summaryrefslogtreecommitdiffstats
path: root/tools/linguist/shared/translator.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-03-26 23:13:30 +0100
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-03-27 12:08:34 +0100
commitd3be9fa7c981430c48de0a65938f3a2bd636bfcc (patch)
tree36ba96ebbab08a5cd770b9f9d731d37e7be63313 /tools/linguist/shared/translator.cpp
parent32798196d81439fa77b34425b95eb47556aebc8d (diff)
properly deal with messages which appear in multiple encodings
in ts 1.1 and qm files, messages appear in their native encoding. that means that a message can appear multiple times - once in utf8 and once in the codecForTr. however, in ts 2.0 files, everything is utf8 and messages can have a utf8 flag for the later transformation into qm. unfortunately, there was no flag to mark that the message is needed in *both* encodings, and the respective case was completely ignored when reading ts 1.1 and qm files (causing error messages). Task-number: 249022 AutoTest: 322690
Diffstat (limited to 'tools/linguist/shared/translator.cpp')
-rw-r--r--tools/linguist/shared/translator.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp
index 32404a5f7a..3721204173 100644
--- a/tools/linguist/shared/translator.cpp
+++ b/tools/linguist/shared/translator.cpp
@@ -114,6 +114,10 @@ void Translator::extend(const TranslatorMessage &msg)
cmt.append(msg.extraComment());
emsg.setExtraComment(cmt);
}
+ if (msg.isUtf8() != emsg.isUtf8()) {
+ emsg.setUtf8(true);
+ emsg.setNonUtf8(true);
+ }
}
}
@@ -425,6 +429,28 @@ QList<TranslatorMessage> Translator::findDuplicates() const
return ret;
}
+void Translator::resolveDualEncoded()
+{
+ QHash<TranslatorMessage, int> dups;
+ for (int i = 0; i < m_messages.count();) {
+ const TranslatorMessage &msg = m_messages.at(i);
+ QHash<TranslatorMessage, int>::ConstIterator it = dups.constFind(msg);
+ if (it != dups.constEnd()) {
+ TranslatorMessage &omsg = m_messages[*it];
+ if (omsg.isUtf8() != msg.isUtf8() && !omsg.isNonUtf8()) {
+ omsg.setUtf8(true);
+ omsg.setNonUtf8(true);
+ m_messages.removeAt(i);
+ continue;
+ }
+ // Regular dupe; will complain later
+ } else {
+ dups[msg] = i;
+ }
+ ++i;
+ }
+}
+
// Used by lupdate to be able to search using absolute paths during merging
void Translator::makeFileNamesAbsolute(const QDir &originalPath)
{