summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs/main.js8
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result27
-rw-r--r--tools/linguist/lupdate/qscript.cpp20
-rw-r--r--tools/linguist/lupdate/qscript.g20
4 files changed, 75 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js b/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js
index edd7529..9f61cea 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js
@@ -81,3 +81,11 @@ qsTr("This string has disambiguation", "Disambiguation");
qsTranslate("BarContext", "This string also has disambiguation", "Another disambiguation");
qsTr("This string contains plurals", "", 10);
+
+qsTrId("qtn_foo_bar");
+
+var more_greeting_strings = [ QT_TRID_NOOP("qtn_needle"), QT_TRID_NOOP("qtn_haystack") ];
+
+//: qsTrId() with comment, meta-data and plurals.
+//~ well-tested True
+qsTrId("qtn_bar_baz", 10);
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result
index d2016de..d03c713 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result
@@ -2,6 +2,33 @@
<!DOCTYPE TS>
<TS version="2.0">
<context>
+ <name></name>
+ <message id="qtn_foo_bar">
+ <location filename="main.js" line="85"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_needle">
+ <location filename="main.js" line="87"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_haystack">
+ <location filename="main.js" line="87"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_bar_baz" numerus="yes">
+ <location filename="main.js" line="91"/>
+ <source></source>
+ <extracomment>qsTrId() with comment, meta-data and plurals.</extracomment>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ <extra-well-tested>True</extra-well-tested>
+ </message>
+</context>
+<context>
<name>BarContext</name>
<message>
<location filename="main.js" line="15"/>
diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp
index dc885a3..7ca0987 100644
--- a/tools/linguist/lupdate/qscript.cpp
+++ b/tools/linguist/lupdate/qscript.cpp
@@ -2310,6 +2310,26 @@ case 66: {
extracomment.clear();
msgid.clear();
extra.clear();
+ } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
+ if (!msgid.isEmpty())
+ yyMsg(identLineNo) << "//= cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ QVariantList args = sym(2).toList();
+ if (args.size() < 1) {
+ yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n";
+ } else {
+ if (args.at(0).type() != QVariant::String) {
+ yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n";
+ } else {
+ msgid = args.at(0).toString();
+ bool plural = (args.size() > 1);
+ recordMessage(translator, QString(), sourcetext, QString(), extracomment,
+ msgid, extra, plural, fileName(), identLineNo);
+ }
+ }
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
}
} break;
diff --git a/tools/linguist/lupdate/qscript.g b/tools/linguist/lupdate/qscript.g
index 200b641..e4c2d22 100644
--- a/tools/linguist/lupdate/qscript.g
+++ b/tools/linguist/lupdate/qscript.g
@@ -1726,6 +1726,26 @@ case $rule_number: {
extracomment.clear();
msgid.clear();
extra.clear();
+ } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
+ if (!msgid.isEmpty())
+ yyMsg(identLineNo) << "//= cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ QVariantList args = sym(2).toList();
+ if (args.size() < 1) {
+ yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n";
+ } else {
+ if (args.at(0).type() != QVariant::String) {
+ yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n";
+ } else {
+ msgid = args.at(0).toString();
+ bool plural = (args.size() > 1);
+ recordMessage(translator, QString(), sourcetext, QString(), extracomment,
+ msgid, extra, plural, fileName(), identLineNo);
+ }
+ }
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
}
} break;
./