summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-08-30 13:26:11 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-08-30 13:43:41 (GMT)
commit47fe98d194e48ec2bac1f75d8b5bd57820d7f66a (patch)
tree7452a56344bbfee2adbd23e2558fc186efbf8664 /tools/linguist
parentedbc656bfa5069dd40f64ae3123d6370c2d86538 (diff)
downloadQt-47fe98d194e48ec2bac1f75d8b5bd57820d7f66a.zip
Qt-47fe98d194e48ec2bac1f75d8b5bd57820d7f66a.tar.gz
Qt-47fe98d194e48ec2bac1f75d8b5bd57820d7f66a.tar.bz2
move the MAGIC_OBSOLETE_REFERENCE hack to the xlf file handler
after all, it is pretty much specific to xlf files, even if the problem majorly concerns converted po files.
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/shared/po.cpp6
-rw-r--r--tools/linguist/shared/xliff.cpp17
2 files changed, 15 insertions, 8 deletions
diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp
index a692332..620d27b 100644
--- a/tools/linguist/shared/po.cpp
+++ b/tools/linguist/shared/po.cpp
@@ -50,8 +50,6 @@
#include <ctype.h>
-#define MAGIC_OBSOLETE_REFERENCE "Obsolete_PO_entries"
-
// Uncomment if you wish to hard wrap long lines in .po files. Note that this
// affects only msg strings, not comments.
//#define HARD_WRAP_LONG_WORDS
@@ -562,8 +560,6 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
if (pos != -1)
msg.addReference(ref.left(pos), ref.mid(pos + 1).toInt());
}
- } else if (isObsolete) {
- msg.setFileName(QLatin1String(MAGIC_OBSOLETE_REFERENCE));
}
msg.setId(codec->toUnicode(item.id));
msg.setSourceText(codec->toUnicode(item.msgId));
@@ -773,7 +769,7 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd)
if (!msg.id().isEmpty())
out << QLatin1String("#. ts-id ") << msg.id() << '\n';
- if (!msg.fileName().isEmpty() && msg.fileName() != QLatin1String(MAGIC_OBSOLETE_REFERENCE)) {
+ if (!msg.fileName().isEmpty()) {
QStringList refs;
foreach (const TranslatorMessage::Reference &ref, msg.allReferences())
refs.append(QString(QLatin1String("%2:%1"))
diff --git a/tools/linguist/shared/xliff.cpp b/tools/linguist/shared/xliff.cpp
index 6411426..70724ef 100644
--- a/tools/linguist/shared/xliff.cpp
+++ b/tools/linguist/shared/xliff.cpp
@@ -53,6 +53,11 @@
#include <QtXml/QXmlParseException>
+// The string value is historical and reflects the main purpose: Keeping
+// obsolete entries separate from the magic file message (which both have
+// no location information, but typically reside at opposite ends of the file).
+#define MAGIC_OBSOLETE_REFERENCE "Obsolete_PO_entries"
+
QT_BEGIN_NAMESPACE
/**
@@ -692,6 +697,9 @@ bool XLIFFHandler::finalizeMessage(bool isPlural)
m_cd.appendError(QLatin1String("XLIFF syntax error: Message without source string."));
return false;
}
+ if (m_type == TranslatorMessage::Obsolete && m_refs.size() == 1
+ && m_refs.at(0).fileName() == QLatin1String(MAGIC_OBSOLETE_REFERENCE))
+ m_refs.clear();
TranslatorMessage msg(m_context, m_sources[0],
m_comment, QString(), QString(), -1,
m_translations, m_type, isPlural);
@@ -761,12 +769,15 @@ bool saveXLIFF(const Translator &translator, QIODevice &dev, ConversionData &cd)
QHash<QString, QList<QString> > contextOrder;
QList<QString> fileOrder;
foreach (const TranslatorMessage &msg, translator.messages()) {
- QHash<QString, QList<TranslatorMessage> > &file = messageOrder[msg.fileName()];
+ QString fn = msg.fileName();
+ if (fn.isEmpty() && msg.type() == TranslatorMessage::Obsolete)
+ fn = QLatin1String(MAGIC_OBSOLETE_REFERENCE);
+ QHash<QString, QList<TranslatorMessage> > &file = messageOrder[fn];
if (file.isEmpty())
- fileOrder.append(msg.fileName());
+ fileOrder.append(fn);
QList<TranslatorMessage> &context = file[msg.context()];
if (context.isEmpty())
- contextOrder[msg.fileName()].append(msg.context());
+ contextOrder[fn].append(msg.context());
context.append(msg);
}