diff options
Diffstat (limited to 'tools/linguist/lupdate/qscript.g')
-rw-r--r-- | tools/linguist/lupdate/qscript.g | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/tools/linguist/lupdate/qscript.g b/tools/linguist/lupdate/qscript.g index e4c2d22..3655f2e 100644 --- a/tools/linguist/lupdate/qscript.g +++ b/tools/linguist/lupdate/qscript.g @@ -84,6 +84,7 @@ /. #include <translator.h> +#include <QtCore/QCoreApplication> #include <QtCore/qdebug.h> #include <QtCore/qnumeric.h> #include <QtCore/qstring.h> @@ -99,6 +100,10 @@ QT_BEGIN_NAMESPACE +class LU { + Q_DECLARE_TR_FUNCTIONS(LUpdate) +}; + static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra, @@ -817,7 +822,7 @@ int QScript::Lexer::lex() else { setDone(Bad); err = IllegalCharacter; - errmsg = QLatin1String("Illegal character"); + errmsg = LU::tr("Illegal character"); } } break; @@ -828,7 +833,7 @@ int QScript::Lexer::lex() } else if (current == 0 || isLineTerminator()) { setDone(Bad); err = UnclosedStringLiteral; - errmsg = QLatin1String("Unclosed string at end of line"); + errmsg = LU::tr("Unclosed string at end of line"); } else if (current == '\\') { state = InEscapeSequence; } else { @@ -854,7 +859,7 @@ int QScript::Lexer::lex() } else { setDone(Bad); err = IllegalEscapeSequence; - errmsg = QLatin1String("Illegal escape squence"); + errmsg = LU::tr("Illegal escape squence"); } } else if (current == 'x') state = InHexEscape; @@ -893,7 +898,7 @@ int QScript::Lexer::lex() } else { setDone(Bad); err = IllegalUnicodeEscapeSequence; - errmsg = QLatin1String("Illegal unicode escape sequence"); + errmsg = LU::tr("Illegal unicode escape sequence"); } break; case InSingleLineComment: @@ -921,7 +926,7 @@ int QScript::Lexer::lex() if (current == 0) { setDone(Bad); err = UnclosedComment; - errmsg = QLatin1String("Unclosed comment at end of file"); + errmsg = LU::tr("Unclosed comment at end of file"); } else if (isLineTerminator()) { shiftWindowsLineBreak(); yylineno++; @@ -1009,7 +1014,7 @@ int QScript::Lexer::lex() } else { setDone(Bad); err = IllegalExponentIndicator; - errmsg = QLatin1String("Illegal syntax for exponential number"); + errmsg = LU::tr("Illegal syntax for exponential number"); } break; case InExponent: @@ -1035,7 +1040,7 @@ int QScript::Lexer::lex() && isIdentLetter(current)) { state = Bad; err = IllegalIdentifier; - errmsg = QLatin1String("Identifier cannot start with numeric literal"); + errmsg = LU::tr("Identifier cannot start with numeric literal"); } // terminate string @@ -1354,7 +1359,7 @@ bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix) while (1) { if (isLineTerminator() || current == 0) { - errmsg = QLatin1String("Unterminated regular expression literal"); + errmsg = LU::tr("Unterminated regular expression literal"); return false; } else if (current != '/' || lastWasEscape == true) @@ -1683,14 +1688,14 @@ case $rule_number: { QString name = sym(1).toString(); if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) { if (!sourcetext.isEmpty()) - yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name)); QVariantList args = sym(2).toList(); if (args.size() < 2) { - yyMsg(identLineNo) << qPrintable(name) << "() requires at least two arguments.\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name)); } else { if ((args.at(0).type() != QVariant::String) || (args.at(1).type() != QVariant::String)) { - yyMsg(identLineNo) << qPrintable(name) << "(): both arguments must be literal strings.\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("%1(): both arguments must be literal strings.\n").arg(name)); } else { QString context = args.at(0).toString(); QString text = args.at(1).toString(); @@ -1706,13 +1711,13 @@ case $rule_number: { extra.clear(); } else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) { if (!sourcetext.isEmpty()) - yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name)); QVariantList args = sym(2).toList(); if (args.size() < 1) { - yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name)); } else { if (args.at(0).type() != QVariant::String) { - yyMsg(identLineNo) << qPrintable(name) << "(): text to translate must be a literal string.\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name)); } else { QString context = QFileInfo(fileName()).baseName(); QString text = args.at(0).toString(); @@ -1728,13 +1733,13 @@ case $rule_number: { 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"; + yyMsg(identLineNo) << qPrintable(LU::tr("//= cannot be used with %1(). Ignoring\n").arg(name)); QVariantList args = sym(2).toList(); if (args.size() < 1) { - yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name)); } else { if (args.at(0).type() != QVariant::String) { - yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n"; + yyMsg(identLineNo) << qPrintable(LU::tr("%1(): identifier must be a literal string.\n").arg(name)); } else { msgid = args.at(0).toString(); bool plural = (args.size() > 1); @@ -1950,7 +1955,7 @@ Statement: DebuggerStatement ; /. case $rule_number: if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) { - yyMsg() << "Discarding unconsumed meta data\n"; + yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n")); sourcetext.clear(); extracomment.clear(); msgid.clear(); @@ -2096,6 +2101,9 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; { if (first) error_message += QLatin1String ("Expected "); + //: Beginning of the string that contains + //: comma-separated list of expected tokens + error_message += LU::tr("Expected "); else error_message += QLatin1String (", "); @@ -2149,13 +2157,13 @@ void QScriptParser::processComment(const QChar *chars, int length) if (isspace(c)) continue; if (c != '"') { - yyMsg() << "Unexpected character in meta string\n"; + yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n")); break; } forever { if (p >= length) { whoops: - yyMsg() << "Unterminated meta string\n"; + yyMsg() << qPrintable(LU::tr("Unterminated meta string\n")); break; } c = chars[p++].unicode(); @@ -2181,8 +2189,7 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData { QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { - cd.appendError(QString::fromLatin1("Cannot open %1: %2") - .arg(filename, file.errorString())); + cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString())); return false; } QTextStream ts(&file); |