diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-11-04 11:17:03 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-11-04 16:24:37 (GMT) |
commit | 9a88c8808f8e084e77ee22f907366250f3a0ad2a (patch) | |
tree | 9813c45e6d1b27264e0d793fddcd1e62546714f1 /tools | |
parent | 1f860338b23d783387b3817de0da100840078edf (diff) | |
download | Qt-9a88c8808f8e084e77ee22f907366250f3a0ad2a.zip Qt-9a88c8808f8e084e77ee22f907366250f3a0ad2a.tar.gz Qt-9a88c8808f8e084e77ee22f907366250f3a0ad2a.tar.bz2 |
add -markuntranslated option
maemo *really* want it, so pushing it in now ...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/lrelease/main.cpp | 9 | ||||
-rw-r--r-- | tools/linguist/shared/qm.cpp | 35 | ||||
-rw-r--r-- | tools/linguist/shared/translator.h | 1 |
3 files changed, 29 insertions, 16 deletions
diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index b32b133..ecaed27 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -79,6 +79,9 @@ static void printUsage() " -removeidentical\n" " If the translated text is the same as\n" " the source text, do not include the message\n" + " -markuntranslated <prefix>\n" + " If a message has no real translation, use the source text\n" + " prefixed with the given string instead\n" " -silent\n" " Do not explain what is being done\n" " -version\n" @@ -183,6 +186,12 @@ int main(int argc, char **argv) } else if (args[i] == QLatin1String("-nounfinished")) { cd.m_ignoreUnfinished = true; continue; + } else if (args[i] == QLatin1String("-markuntranslated")) { + if (i == argc - 1) { + printUsage(); + return 1; + } + cd.m_unTrPrefix = args[++i]; } else if (args[i] == QLatin1String("-silent")) { cd.m_verbose = false; continue; diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 317a07e..5965aac 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -172,8 +172,8 @@ public: bool save(QIODevice *iod); - void insert(const TranslatorMessage &msg, bool forceComment); - void insertIdBased(const TranslatorMessage &message); + void insert(const TranslatorMessage &msg, const QStringList &tlns, bool forceComment); + void insertIdBased(const TranslatorMessage &message, const QStringList &tlns); void squeeze(TranslatorSaveMode mode); @@ -186,7 +186,8 @@ private: // on turn should be the same as passed to the actual tr(...) calls QByteArray originalBytes(const QString &str, bool isUtf8) const; - void insertInternal(const TranslatorMessage &message, bool forceComment, bool isUtf8); + void insertInternal(const TranslatorMessage &message, const QStringList &tlns, + bool forceComment, bool isUtf8); static Prefix commonPrefix(const ByteTranslatorMessage &m1, const ByteTranslatorMessage &m2); @@ -413,12 +414,13 @@ void Releaser::squeeze(TranslatorSaveMode mode) } } -void Releaser::insertInternal(const TranslatorMessage &message, bool forceComment, bool isUtf8) +void Releaser::insertInternal(const TranslatorMessage &message, const QStringList &tlns, + bool forceComment, bool isUtf8) { ByteTranslatorMessage bmsg(originalBytes(message.context(), isUtf8), originalBytes(message.sourceText(), isUtf8), originalBytes(message.comment(), isUtf8), - message.translations()); + tlns); if (!forceComment) { ByteTranslatorMessage bmsg2( bmsg.context(), bmsg.sourceText(), QByteArray(""), bmsg.translations()); @@ -430,20 +432,15 @@ void Releaser::insertInternal(const TranslatorMessage &message, bool forceCommen m_messages.insert(bmsg, 0); } -void Releaser::insert(const TranslatorMessage &message, bool forceComment) +void Releaser::insert(const TranslatorMessage &message, const QStringList &tlns, bool forceComment) { - insertInternal(message, forceComment, message.isUtf8()); + insertInternal(message, tlns, forceComment, message.isUtf8()); if (message.isUtf8() && message.isNonUtf8()) - insertInternal(message, forceComment, false); + insertInternal(message, tlns, forceComment, false); } -void Releaser::insertIdBased(const TranslatorMessage &message) +void Releaser::insertIdBased(const TranslatorMessage &message, const QStringList &tlns) { - QStringList tlns = message.translations(); - if (message.type() == TranslatorMessage::Unfinished) - for (int i = 0; i < tlns.size(); ++i) - if (tlns.at(i).isEmpty()) - tlns[i] = message.sourceText(); ByteTranslatorMessage bmsg("", originalBytes(message.id(), false), "", tlns); m_messages.insert(bmsg, 0); } @@ -725,10 +722,16 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData } else { ++finished; } + QStringList tlns = msg.translations(); + if (msg.type() == TranslatorMessage::Unfinished + && (cd.m_idBased || !cd.m_unTrPrefix.isEmpty())) + for (int j = 0; j < tlns.size(); ++j) + if (tlns.at(j).isEmpty()) + tlns[j] = cd.m_unTrPrefix + msg.sourceText(); if (cd.m_idBased) { if (!msg.context().isEmpty() || !msg.comment().isEmpty()) ++droppedData; - releaser.insertIdBased(msg); + releaser.insertIdBased(msg, tlns); } else { // Drop the comment in (context, sourceText, comment), // unless the context is empty, @@ -739,7 +742,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData msg.comment().isEmpty() || msg.context().isEmpty() || translator.contains(msg.context(), msg.sourceText(), QString()); - releaser.insert(msg, forceComment); + releaser.insert(msg, tlns, forceComment); } } } diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 1dd6a59..ef81d2a 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -86,6 +86,7 @@ public: QString m_defaultContext; QByteArray m_codecForSource; // CPP, PO & QM specific QByteArray m_outputCodec; // PO specific + QString m_unTrPrefix; // QM specific QString m_sourceFileName; QString m_targetFileName; QDir m_sourceDir; |