summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-05 15:19:02 +0100
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-06 22:58:01 +0100
commit0a1db39ba70060f305e5694d1a12dd3c2e5bca4c (patch)
tree0e5786d7497ac56e2ef0ba2a665c7b0d642a4c62
parenta66698f947e8ded2e020defa626b154aca1fde9f (diff)
record id-based messages even if they have an empty source
this makes sense if one uses lupdate only for validation purposes, i.e. to find out if the code uses only ids which are defined in some external specification.
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp4
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before4
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result6
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp5
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result6
-rw-r--r--tools/linguist/lupdate/cpp.cpp26
-rw-r--r--tools/linguist/lupdate/merge.cpp6
-rw-r--r--tools/linguist/shared/translator.cpp4
8 files changed, 41 insertions, 20 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
index f27e1f036c..5bd7a0a1f5 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
@@ -75,4 +75,8 @@ void FindDialog::reset()
//= new_id
tr("this is just some text");
+
+
+ //: A message without source string
+ qtTrId("qtn_virtual");
}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
index ad2f65fd49..379cce465c 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
@@ -12,6 +12,10 @@
<source>World</source>
<translation>Welt</translation>
</message>
+ <message id="qtn_virtual">
+ <location filename="finddialog.cpp" line="79"/>
+ <extracomment>A message without source string</extracomment>
+ </message>
</context>
<context>
<name>FindDialog</name>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
index e9abf89587..de43266d29 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
@@ -14,6 +14,12 @@
<oldsource>World</oldsource>
<translation type="unfinished">Welt</translation>
</message>
+ <message id="qtn_virtual">
+ <location filename="finddialog.cpp" line="81"/>
+ <source></source>
+ <extracomment>A message without source string</extracomment>
+ <translation></translation>
+ </message>
</context>
<context>
<name>FindDialog</name>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index e243e662fb..386d9b7194 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -247,3 +247,8 @@ class YetAnotherTest : QObject {
tr("nothing");
}
};
+
+
+
+//: This is a message without a source string
+QString test = qtTrId("yet_another_id");
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
index 26e5a65f22..6d50c21c0d 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -18,6 +18,12 @@ backslashed \ stuff.</source>
</translation>
<extra-some>thing</extra-some>
</message>
+ <message id="yet_another_id">
+ <location filename="main.cpp" line="254"/>
+ <source></source>
+ <extracomment>This is a message without a source string</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>Dialog2</name>
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index fb95a95f8a..443abd0f3a 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -1883,22 +1883,18 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
case Tok_trid:
if (!tor)
goto case_default;
- if (sourcetext.isEmpty()) {
- yyTok = getToken();
- } else {
- if (!msgid.isEmpty())
- qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n",
- qPrintable(yyFileName), yyLineNo);
- //utf8 = false; // Maybe use //%% or something like that
- line = yyLineNo;
- yyTok = getToken();
- if (match(Tok_LeftParen) && matchString(&msgid) && !msgid.isEmpty()) {
- bool plural = match(Tok_Comma);
- recordMessage(line, QString(), sourcetext, QString(), extracomment,
- msgid, extra, false, plural);
- }
- sourcetext.clear();
+ if (!msgid.isEmpty())
+ qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n",
+ qPrintable(yyFileName), yyLineNo);
+ //utf8 = false; // Maybe use //%% or something like that
+ line = yyLineNo;
+ yyTok = getToken();
+ if (match(Tok_LeftParen) && matchString(&msgid) && !msgid.isEmpty()) {
+ bool plural = match(Tok_Comma);
+ recordMessage(line, QString(), sourcetext, QString(), extracomment,
+ msgid, extra, false, plural);
}
+ sourcetext.clear();
extracomment.clear();
msgid.clear();
extra.clear();
diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp
index a72143939a..fa0dd3d82b 100644
--- a/tools/linguist/lupdate/merge.cpp
+++ b/tools/linguist/lupdate/merge.cpp
@@ -341,7 +341,7 @@ Translator merge(const Translator &tor, const Translator &virginTor,
foreach (TranslatorMessage m, tor.messages()) {
TranslatorMessage::Type newType = TranslatorMessage::Finished;
- if (m.sourceText().isEmpty()) {
+ if (m.sourceText().isEmpty() && m.id().isEmpty()) {
// context/file comment
TranslatorMessage mv = virginTor.find(m.context());
if (!mv.isNull())
@@ -447,7 +447,7 @@ Translator merge(const Translator &tor, const Translator &virginTor,
vernacular translator.
*/
foreach (const TranslatorMessage &mv, virginTor.messages()) {
- if (mv.sourceText().isEmpty()) {
+ if (mv.sourceText().isEmpty() && mv.id().isEmpty()) {
if (tor.contains(mv.context()))
continue;
} else {
@@ -465,7 +465,7 @@ Translator merge(const Translator &tor, const Translator &virginTor,
outTor.append(mv);
else
outTor.appendSorted(mv);
- if (!mv.sourceText().isEmpty())
+ if (!mv.sourceText().isEmpty() || !mv.id().isEmpty())
++neww;
}
diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp
index 77faabda51..bc27daf27f 100644
--- a/tools/linguist/shared/translator.cpp
+++ b/tools/linguist/shared/translator.cpp
@@ -337,7 +337,7 @@ TranslatorMessage Translator::find(const QString &context,
bool Translator::contains(const QString &context) const
{
foreach (const TranslatorMessage &msg, m_messages)
- if (msg.context() == context && msg.sourceText().isEmpty())
+ if (msg.context() == context && msg.sourceText().isEmpty() && msg.id().isEmpty())
return true;
return false;
}
@@ -345,7 +345,7 @@ bool Translator::contains(const QString &context) const
TranslatorMessage Translator::find(const QString &context) const
{
foreach (const TranslatorMessage &msg, m_messages)
- if (msg.context() == context && msg.sourceText().isEmpty())
+ if (msg.context() == context && msg.sourceText().isEmpty() && msg.id().isEmpty())
return msg;
return TranslatorMessage();
}