From 8ccd6b9dfea90b9d12b77d789484fbb5881b1463 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 20 May 2009 12:34:24 +1000 Subject: Add support for qsTranslate, QT_TR_NOOP, and QT_TRANSLATE_NOOP. --- tools/linguist/lupdate/qml.cpp | 43 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/tools/linguist/lupdate/qml.cpp b/tools/linguist/lupdate/qml.cpp index 6eec72e..78a9afd 100644 --- a/tools/linguist/lupdate/qml.cpp +++ b/tools/linguist/lupdate/qml.cpp @@ -88,7 +88,8 @@ protected: virtual void endVisit(AST::CallExpression *node) { if (AST::IdentifierExpression *idExpr = AST::cast(node->base)) { - if (idExpr->name->asString() == QLatin1String("qsTr")) { + if (idExpr->name->asString() == QLatin1String("qsTr") || + idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) { if (node->arguments && AST::cast(node->arguments->expression)) { AST::StringLiteral *literal = AST::cast(node->arguments->expression); const QString source = literal->value->asString(); @@ -102,8 +103,8 @@ protected: AST::ArgumentList *nNode = commentNode->next; if (nNode) { - AST::NumericLiteral *literal3 = AST::cast(nNode->expression); - if (literal3) { + AST::NumericLiteral *numLiteral = AST::cast(nNode->expression); + if (numLiteral) { plural = true; } } @@ -115,8 +116,42 @@ protected: TranslatorMessage::Unfinished, plural); m_translator->extend(msg); } + } else if (idExpr->name->asString() == QLatin1String("qsTranslate") || + idExpr->name->asString() == QLatin1String("QT_TRANSLATE_NOOP")) { + if (node->arguments && AST::cast(node->arguments->expression)) { + AST::StringLiteral *literal = AST::cast(node->arguments->expression); + const QString context = literal->value->asString(); + + QString source; + QString comment; + bool plural = false; + AST::ArgumentList *sourceNode = node->arguments->next; + if (sourceNode) { + literal = AST::cast(sourceNode->expression); + source = literal->value->asString(); + AST::ArgumentList *commentNode = sourceNode->next; + if (commentNode) { + literal = AST::cast(commentNode->expression); + comment = literal->value->asString(); + + AST::ArgumentList *nNode = commentNode->next; + if (nNode) { + AST::NumericLiteral *numLiteral = AST::cast(nNode->expression); + if (numLiteral) { + plural = true; + } + } + } + } + + TranslatorMessage msg(context, source, + comment, QString(), m_fileName, + node->firstSourceLocation().startLine, QStringList(), + TranslatorMessage::Unfinished, plural); + m_translator->extend(msg); + } + } - //### support qsTranslate, QT_TR_NOOP, and QT_TRANSLATE_NOOP } } -- cgit v0.12