summaryrefslogtreecommitdiffstats
path: root/src/linguist/lupdate/qdeclarative.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-11-26 15:06:17 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-09 17:39:12 +0200
commiteec0eaed067dc1b421e12530c70b3a4ee01affee (patch)
tree3e01e001b5a2d1ef5f0ace13de3977394d1d5592 /src/linguist/lupdate/qdeclarative.cpp
parentd07d47cf85f4026c8cb508fe9977fff5ffdbd810 (diff)
lupdate: allow to configure names of tr()-like functions
This makes it possible to use lupdate in projects that would like to wrap the tr()-like functions with their own versions, e.g. to add error checking or other instrumentation code. While we're at it, also simplify the c++ parsing with partly table-driven code. Change-Id: I72af68afa851a46342e75dcdd3dd58f4c14276b8 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'src/linguist/lupdate/qdeclarative.cpp')
-rw-r--r--src/linguist/lupdate/qdeclarative.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp
index befeea235..3a18b9755 100644
--- a/src/linguist/lupdate/qdeclarative.cpp
+++ b/src/linguist/lupdate/qdeclarative.cpp
@@ -107,8 +107,9 @@ protected:
const QString name = idExpr->name.toString();
const int identLineNo = idExpr->identifierToken.startLine;
- if (name == QLatin1String("qsTr") ||
- name == QLatin1String("QT_TR_NOOP")) {
+ switch (trFunctionAliasManager.trFunctionByName(name)) {
+ case TrFunctionAliasManager::Function_qsTr:
+ case TrFunctionAliasManager::Function_QT_TR_NOOP: {
if (!node->arguments) {
yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
return;
@@ -142,8 +143,9 @@ protected:
msg.setExtras(extra);
m_translator->extend(msg);
consumeComment();
- } else if (name == QLatin1String("qsTranslate") ||
- name == QLatin1String("QT_TRANSLATE_NOOP")) {
+ break; }
+ case TrFunctionAliasManager::Function_qsTranslate:
+ case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP: {
if (! (node->arguments && node->arguments->next)) {
yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name));
return;
@@ -186,8 +188,9 @@ protected:
msg.setExtras(extra);
m_translator->extend(msg);
consumeComment();
- } else if (name == QLatin1String("qsTrId") ||
- name == QLatin1String("QT_TRID_NOOP")) {
+ break; }
+ case TrFunctionAliasManager::Function_qsTrId:
+ case TrFunctionAliasManager::Function_QT_TRID_NOOP: {
if (!node->arguments) {
yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
return;
@@ -215,6 +218,7 @@ protected:
msg.setExtras(extra);
m_translator->extend(msg);
consumeComment();
+ break; }
}
}
}