diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-05-25 17:56:39 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-05-25 18:00:48 (GMT) |
commit | ef4c47d8b4dc9b2056541cd29686b0959fd778a4 (patch) | |
tree | 2914e8820fdf83f2da83587ac3f9f75d87e86301 /tools | |
parent | 675e9e645fb596ae822fb10093bea25a47a78488 (diff) | |
download | Qt-ef4c47d8b4dc9b2056541cd29686b0959fd778a4.zip Qt-ef4c47d8b4dc9b2056541cd29686b0959fd778a4.tar.gz Qt-ef4c47d8b4dc9b2056541cd29686b0959fd778a4.tar.bz2 |
implement --no-ui-lines option (complementing lupdate)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/lconvert/main.cpp | 7 | ||||
-rw-r--r-- | tools/linguist/shared/translator.cpp | 20 | ||||
-rw-r--r-- | tools/linguist/shared/translator.h | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index bdc6c9a..52bf91f 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -97,6 +97,8 @@ static int usage(const QStringList &args) " Drop obsolete messages.\n\n" " --no-finished\n" " Drop finished messages.\n\n" + " --no-ui-lines\n" + " Drop line numbers from references to .ui files.\n\n" " --verbose\n" " be a bit more verbose\n\n" "Long options can be specified with only one leading dash, too.\n\n" @@ -129,6 +131,7 @@ int main(int argc, char *argv[]) bool noObsolete = false; bool noFinished = false; bool verbose = false; + bool noUiLines = false; ConversionData cd; Translator tr; @@ -180,6 +183,8 @@ int main(int argc, char *argv[]) noObsolete = true; } else if (args[i] == QLatin1String("-no-finished")) { noFinished = true; + } else if (args[i] == QLatin1String("-no-ui-lines")) { + noUiLines = true; } else if (args[i] == QLatin1String("-verbose")) { verbose = true; } else if (args[i].startsWith(QLatin1Char('-'))) { @@ -224,6 +229,8 @@ int main(int argc, char *argv[]) tr.stripFinishedMessages(); if (dropTranslations) tr.dropTranslations(); + if (noUiLines) + tr.dropUiLines(); if (!tr.save(outFileName, cd, outFormat)) { qWarning("%s", qPrintable(cd.error())); diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 312bb71..c1f242d 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -416,6 +416,26 @@ void Translator::dropTranslations() } } +void Translator::dropUiLines() +{ + QString uiXt = QLatin1String(".ui"); + QString juiXt = QLatin1String(".jui"); + for (TMM::Iterator it = m_messages.begin(); it != m_messages.end(); ++it) { + QHash<QString, int> have; + QList<TranslatorMessage::Reference> refs; + foreach (const TranslatorMessage::Reference &itref, it->allReferences()) { + const QString &fn = itref.fileName(); + if (fn.endsWith(uiXt) || fn.endsWith(juiXt)) { + if (++have[fn] == 1) + refs.append(TranslatorMessage::Reference(fn, -1)); + } else { + refs.append(itref); + } + } + it->setReferences(refs); + } +} + QSet<TranslatorMessagePtr> Translator::resolveDuplicates() { QSet<TranslatorMessagePtr> dups; diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 4e97000..3dda41a 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -132,6 +132,7 @@ public: void stripNonPluralForms(); void stripIdenticalSourceTranslations(); void dropTranslations(); + void dropUiLines(); void makeFileNamesAbsolute(const QDir &originalPath); QSet<TranslatorMessagePtr> resolveDuplicates(); static void reportDuplicates(const QSet<TranslatorMessagePtr> &dupes, |