summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-01-09 12:10:24 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-01-09 12:10:24 (GMT)
commit32d84d886b6c593b5f41f56ecdc418f6638b1f07 (patch)
treec13f6cd77c5d6963f833b280ca707a5461b6f05b /tools
parentec82a2e2c596fd623c58a4a003dd2e7603931993 (diff)
parent0cd3782fde0da7149771db1c97f1fa6f358564d4 (diff)
downloadQt-32d84d886b6c593b5f41f56ecdc418f6638b1f07.zip
Qt-32d84d886b6c593b5f41f56ecdc418f6638b1f07.tar.gz
Qt-32d84d886b6c593b5f41f56ecdc418f6638b1f07.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1: Doc typos fixed Translations: Update German for 4.6.1 fix test under windows don't complain about unresolved base when the reference is absolute make the lupdate tests more verbose in case of failure don't use qmake for test setup move equivalent of output_ts test to good/ look for the .result file in the dir where the output is expected to go fix sametext and number heuristics fix number heuristics, part 1 no point in specifying -ts when a .pro file is specified clean up the lupdatecmd files tidy up the test .pro files remove dead code
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/lupdate/cpp.cpp2
-rw-r--r--tools/linguist/lupdate/main.cpp8
-rw-r--r--tools/linguist/lupdate/merge.cpp95
3 files changed, 49 insertions, 56 deletions
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 857233e..b7f7807 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -1732,7 +1732,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
plural = true;
}
}
- if (!pendingContext.isEmpty()) {
+ if (!pendingContext.isEmpty() && !prefix.startsWith(strColons)) {
QStringList unresolved;
if (!fullyQualify(namespaces, pendingContext, true, &functionContext, &unresolved)) {
functionContextUnresolved = unresolved.join(strColons);
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index 9a9af68..a0ab7f9 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -237,18 +237,12 @@ int main(int argc, char **argv)
Verbose | // verbose is on by default starting with Qt 4.2
HeuristicSameText | HeuristicSimilarText | HeuristicNumber;
int numFiles = 0;
- bool standardSyntax = true;
bool metTsFlag = false;
bool recursiveScan = true;
QString extensions = m_defaultExtensions;
QSet<QString> extensionsNameFilters;
- for (int i = 1; i < argc; ++i) {
- if (args.at(i) == QLatin1String("-ts"))
- standardSyntax = false;
- }
-
for (int i = 1; i < argc; ++i) {
QString arg = args.at(i);
if (arg == QLatin1String("-help")
@@ -375,8 +369,6 @@ int main(int argc, char **argv)
numFiles++;
- QString fullText;
-
codecForTr.clear();
codecForSource.clear();
diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp
index fa0dd3d..b657282 100644
--- a/tools/linguist/lupdate/merge.cpp
+++ b/tools/linguist/lupdate/merge.cpp
@@ -50,9 +50,6 @@
#include <QtCore/QTextCodec>
#include <QtCore/QVector>
-typedef QList<TranslatorMessage> TML;
-typedef QMap<QString, TranslatorMessage> TMM;
-
QT_BEGIN_NAMESPACE
@@ -63,7 +60,7 @@ static bool isDigitFriendly(QChar c)
static int numberLength(const QString &s, int i)
{
- if (i < s.size() || !s.at(i).isDigit())
+ if (i >= s.size() || !s.at(i).isDigit())
return 0;
int pos = i;
@@ -90,7 +87,7 @@ static QString zeroKey(const QString &key)
QString zeroed;
bool metSomething = false;
- for (int i = 0; i != key.size(); ++i) {
+ for (int i = 0; i < key.size(); ++i) {
int len = numberLength(key, i);
if (len > 0) {
i += len;
@@ -225,31 +222,36 @@ static QString translationAttempt(const QString &oldTranslation,
*/
int applyNumberHeuristic(Translator &tor)
{
- TMM translated, untranslated;
- TMM::Iterator t, u;
- TML all = tor.messages();
- TML::Iterator it;
+ QMap<QString, QPair<QString, QString> > translated;
+ QVector<bool> untranslated(tor.messageCount());
int inserted = 0;
- for (it = all.begin(); it != all.end(); ++it) {
- bool hasTranslation = it->isTranslated();
- if (it->type() == TranslatorMessage::Unfinished) {
+ for (int i = 0; i < tor.messageCount(); ++i) {
+ const TranslatorMessage &msg = tor.message(i);
+ bool hasTranslation = msg.isTranslated();
+ if (msg.type() == TranslatorMessage::Unfinished) {
if (!hasTranslation)
- untranslated.insert(it->context() + QLatin1Char('\n')
- + it->sourceText() + QLatin1Char('\n')
- + it->comment(), *it);
- } else if (hasTranslation && it->translations().count() == 1) {
- translated.insert(zeroKey(it->sourceText()), *it);
+ untranslated[i] = true;
+ } else if (hasTranslation && msg.translations().count() == 1) {
+ const QString &key = zeroKey(msg.sourceText());
+ if (!key.isEmpty())
+ translated.insert(key, qMakePair(msg.sourceText(), msg.translation()));
}
}
- for (u = untranslated.begin(); u != untranslated.end(); ++u) {
- t = translated.find(zeroKey((*u).sourceText()));
- if (t != translated.end() && !t.key().isEmpty()
- && t->sourceText() != u->sourceText()) {
- u->setTranslation(translationAttempt(t->translation(), t->sourceText(),
- u->sourceText()));
- inserted++;
+ for (int i = 0; i < tor.messageCount(); ++i) {
+ if (untranslated[i]) {
+ TranslatorMessage &msg = tor.message(i);
+ const QString &key = zeroKey(msg.sourceText());
+ if (!key.isEmpty()) {
+ QMap<QString, QPair<QString, QString> >::ConstIterator t =
+ translated.constFind(key);
+ if (t != translated.constEnd() && t->first != msg.sourceText()) {
+ msg.setTranslation(translationAttempt(t->second, t->first,
+ msg.sourceText()));
+ inserted++;
+ }
+ }
}
}
return inserted;
@@ -268,43 +270,42 @@ int applyNumberHeuristic(Translator &tor)
int applySameTextHeuristic(Translator &tor)
{
- TMM translated;
- TMM avoid;
- TMM::Iterator t;
- TML untranslated;
- TML::Iterator u;
- TML all = tor.messages();
- TML::Iterator it;
+ QMap<QString, QStringList> translated;
+ QMap<QString, bool> avoid; // Want a QTreeSet, in fact
+ QVector<bool> untranslated(tor.messageCount());
int inserted = 0;
- for (it = all.begin(); it != all.end(); ++it) {
- if (!it->isTranslated()) {
- if (it->type() == TranslatorMessage::Unfinished)
- untranslated.append(*it);
+ for (int i = 0; i < tor.messageCount(); ++i) {
+ const TranslatorMessage &msg = tor.message(i);
+ if (!msg.isTranslated()) {
+ if (msg.type() == TranslatorMessage::Unfinished)
+ untranslated[i] = true;
} else {
- QString key = it->sourceText();
- t = translated.find(key);
- if (t != translated.end()) {
+ const QString &key = msg.sourceText();
+ QMap<QString, QStringList>::ConstIterator t = translated.constFind(key);
+ if (t != translated.constEnd()) {
/*
The same source text is translated at least two
different ways. Do nothing then.
*/
- if (t->translations() != it->translations()) {
+ if (*t != msg.translations()) {
translated.remove(key);
- avoid.insert(key, *it);
+ avoid.insert(key, true);
}
} else if (!avoid.contains(key)) {
- translated.insert(key, *it);
+ translated.insert(key, msg.translations());
}
}
}
- for (u = untranslated.begin(); u != untranslated.end(); ++u) {
- QString key = u->sourceText();
- t = translated.find(key);
- if (t != translated.end()) {
- u->setTranslations(t->translations());
- ++inserted;
+ for (int i = 0; i < tor.messageCount(); ++i) {
+ if (untranslated[i]) {
+ TranslatorMessage &msg = tor.message(i);
+ QMap<QString, QStringList>::ConstIterator t = translated.constFind(msg.sourceText());
+ if (t != translated.constEnd()) {
+ msg.setTranslations(*t);
+ ++inserted;
+ }
}
}
return inserted;