diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-02-07 10:39:22 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-07 12:36:00 +0100 |
commit | 41dfd254c3a972fd77389713d0e370b98247a12d (patch) | |
tree | 06f4e97c5aded6a1a12b7f8d8b94e83fba7ef8ce | |
parent | 5221ae5f424f24000d877d2a4394e2d75a052cca (diff) | |
download | qtbase-41dfd254c3a972fd77389713d0e370b98247a12d.tar.gz |
qdoc: Fix translation contexts.
Put all translations into the namespace QDoc and fix warnings
about invalid tr()-usage by removing the free tr()-function
from tr.h. Provide QCoreApplication::translate() for bootstrap
builds.
Change-Id: I2b6931188346f290e80e14b84adff8892d8a860f
Reviewed-by: Martin Smith <martin.smith@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
29 files changed, 85 insertions, 29 deletions
diff --git a/src/tools/qdoc/atom.cpp b/src/tools/qdoc/atom.cpp index 481cfffd75..6f9da3790d 100644 --- a/src/tools/qdoc/atom.cpp +++ b/src/tools/qdoc/atom.cpp @@ -349,7 +349,7 @@ QString Atom::typeString() const int i = 0; while (atms[i].english != 0) { if (atms[i].no != i) - Location::internalError(tr("atom %1 missing").arg(i)); + Location::internalError(QCoreApplication::translate("QDoc::Atom", "atom %1 missing").arg(i)); i++; } deja = true; diff --git a/src/tools/qdoc/codeparser.h b/src/tools/qdoc/codeparser.h index cbb8544d6f..8c398aeb05 100644 --- a/src/tools/qdoc/codeparser.h +++ b/src/tools/qdoc/codeparser.h @@ -54,6 +54,8 @@ class QDocDatabase; class CodeParser { + Q_DECLARE_TR_FUNCTIONS(QDoc::CodeParser) + public: CodeParser(); virtual ~CodeParser(); diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp index 9b58df19ee..766697dfc2 100644 --- a/src/tools/qdoc/config.cpp +++ b/src/tools/qdoc/config.cpp @@ -88,6 +88,8 @@ void MetaStackEntry::close() */ class MetaStack : private QStack<MetaStackEntry> { + Q_DECLARE_TR_FUNCTIONS(QDoc::MetaStack) + public: MetaStack(); diff --git a/src/tools/qdoc/config.h b/src/tools/qdoc/config.h index 419329797b..2c655cdf23 100644 --- a/src/tools/qdoc/config.h +++ b/src/tools/qdoc/config.h @@ -72,6 +72,8 @@ typedef QMap<QString, QStringListPair> QStringListPairMap; class Config { + Q_DECLARE_TR_FUNCTIONS(QDoc::Config) + public: Config(const QString& programName); ~Config(); diff --git a/src/tools/qdoc/cppcodemarker.h b/src/tools/qdoc/cppcodemarker.h index f4bdca0133..91a9c01a28 100644 --- a/src/tools/qdoc/cppcodemarker.h +++ b/src/tools/qdoc/cppcodemarker.h @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE class CppCodeMarker : public CodeMarker { + Q_DECLARE_TR_FUNCTIONS(QDoc::CppCodeMarker) + public: CppCodeMarker(); ~CppCodeMarker(); diff --git a/src/tools/qdoc/cppcodeparser.h b/src/tools/qdoc/cppcodeparser.h index 72c5907166..24b1f4c05a 100644 --- a/src/tools/qdoc/cppcodeparser.h +++ b/src/tools/qdoc/cppcodeparser.h @@ -57,6 +57,8 @@ class Tokenizer; class CppCodeParser : public CodeParser { + Q_DECLARE_TR_FUNCTIONS(QDoc::CppCodeParser) + public: CppCodeParser(); ~CppCodeParser(); diff --git a/src/tools/qdoc/ditaxmlgenerator.h b/src/tools/qdoc/ditaxmlgenerator.h index 95e034bc43..c096829cae 100644 --- a/src/tools/qdoc/ditaxmlgenerator.h +++ b/src/tools/qdoc/ditaxmlgenerator.h @@ -56,6 +56,8 @@ typedef QMap<QString, GuidMap*> GuidMaps; class DitaXmlGenerator : public Generator { + Q_DECLARE_TR_FUNCTIONS(QDoc::DitaXmlGenerator) + public: enum SinceType { Namespace, diff --git a/src/tools/qdoc/doc.cpp b/src/tools/qdoc/doc.cpp index 3154578766..a0a2e51198 100644 --- a/src/tools/qdoc/doc.cpp +++ b/src/tools/qdoc/doc.cpp @@ -439,6 +439,8 @@ bool DocPrivate::isEnumDocSimplifiable() const class DocParser { + Q_DECLARE_TR_FUNCTIONS(QDoc::DocParser) + public: void parse(const QString &source, DocPrivate *docPrivate, diff --git a/src/tools/qdoc/doc.h b/src/tools/qdoc/doc.h index abbe231a46..ca9787595f 100644 --- a/src/tools/qdoc/doc.h +++ b/src/tools/qdoc/doc.h @@ -121,6 +121,8 @@ public: class Doc { + Q_DECLARE_TR_FUNCTIONS(QDoc::Doc) + public: // the order is important enum Sections { diff --git a/src/tools/qdoc/generator.h b/src/tools/qdoc/generator.h index 551196f2f4..e4bc85b2bc 100644 --- a/src/tools/qdoc/generator.h +++ b/src/tools/qdoc/generator.h @@ -66,6 +66,8 @@ class QDocDatabase; class Generator { + Q_DECLARE_TR_FUNCTIONS(QDoc::Generator) + public: enum Passes { Both, Prepare, Generate }; diff --git a/src/tools/qdoc/helpprojectwriter.h b/src/tools/qdoc/helpprojectwriter.h index adca31d814..0ca3043223 100644 --- a/src/tools/qdoc/helpprojectwriter.h +++ b/src/tools/qdoc/helpprojectwriter.h @@ -85,6 +85,8 @@ struct HelpProject class HelpProjectWriter { + Q_DECLARE_TR_FUNCTIONS(QDoc::HelpProjectWriter) + public: HelpProjectWriter(const Config &config, const QString &defaultFileName, diff --git a/src/tools/qdoc/htmlgenerator.h b/src/tools/qdoc/htmlgenerator.h index 132fb0927a..65d874f619 100644 --- a/src/tools/qdoc/htmlgenerator.h +++ b/src/tools/qdoc/htmlgenerator.h @@ -59,6 +59,8 @@ class HelpProjectWriter; class HtmlGenerator : public Generator { + Q_DECLARE_TR_FUNCTIONS(QDoc::HtmlGenerator) + public: enum SinceType { Namespace, diff --git a/src/tools/qdoc/jscodemarker.h b/src/tools/qdoc/jscodemarker.h index 59b1776728..123e3e2db7 100644 --- a/src/tools/qdoc/jscodemarker.h +++ b/src/tools/qdoc/jscodemarker.h @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE class JsCodeMarker : public QmlCodeMarker { + Q_DECLARE_TR_FUNCTIONS(QDoc::JsCodeMarker) + public: JsCodeMarker(); ~JsCodeMarker(); diff --git a/src/tools/qdoc/location.h b/src/tools/qdoc/location.h index 87aa9b5893..20ddfd076e 100644 --- a/src/tools/qdoc/location.h +++ b/src/tools/qdoc/location.h @@ -57,6 +57,8 @@ class QRegExp; class Location { + Q_DECLARE_TR_FUNCTIONS(QDoc::Location) + public: Location(); Location(const QString& filePath); diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp index 2625782cfb..348023b750 100644 --- a/src/tools/qdoc/main.cpp +++ b/src/tools/qdoc/main.cpp @@ -110,7 +110,7 @@ static QString documentationPath; */ static void printHelp() { - Location::information(tr("Usage: qdoc [options] file1.qdocconf ...\n" + Location::information(QCoreApplication::translate("QDoc", "Usage: qdoc [options] file1.qdocconf ...\n" "Options:\n" " -D<name> " "Define <name> as a macro while parsing sources\n" @@ -149,7 +149,7 @@ static void printHelp() */ static void printVersion() { - QString s = tr("qdoc version %1").arg(QT_VERSION_STR); + QString s = QCoreApplication::translate("QDoc", "qdoc version %1").arg(QT_VERSION_STR); Location::information(s); } @@ -250,7 +250,7 @@ static void processQdocconfFile(const QString &fileName) All the other classes are initialized with the config. Here we initialize the configuration with some default values. */ - Config config(tr("qdoc")); + Config config(QCoreApplication::translate("QDoc", "qdoc")); int i = 0; while (defaults[i].key) { config.setStringList(defaults[i].key, QStringList() << defaults[i].value); @@ -325,7 +325,7 @@ static void processQdocconfFile(const QString &fileName) while (fn != fileNames.constEnd()) { QTranslator *translator = new QTranslator(0); if (!translator->load(*fn)) - config.lastLocation().error(tr("Cannot load translator '%1'").arg(*fn)); + config.lastLocation().error(QCoreApplication::translate("QDoc", "Cannot load translator '%1'").arg(*fn)); QCoreApplication::instance()->installTranslator(translator); translators.append(translator); ++fn; @@ -489,7 +489,7 @@ static void processQdocconfFile(const QString &fileName) while (of != outputFormats.constEnd()) { Generator* generator = Generator::generatorForFormat(*of); if (generator == 0) - outputFormatsLocation.fatal(tr("Unknown output format '%1'").arg(*of)); + outputFormatsLocation.fatal(QCoreApplication::translate("QDoc", "Unknown output format '%1'").arg(*of)); generator->generateTree(); ++of; } diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 56da4ca174..11c08fb659 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -69,6 +69,8 @@ typedef QList<QPair<QString,QString> > ImportList; class Node { + Q_DECLARE_TR_FUNCTIONS(QDoc::Node) + public: enum Type { Namespace, @@ -596,6 +598,8 @@ class QmlPropertyNode; class QmlPropertyNode : public LeafNode { + Q_DECLARE_TR_FUNCTIONS(QDoc::QmlPropertyNode) + public: QmlPropertyNode(QmlClassNode *parent, const QString& name, diff --git a/src/tools/qdoc/openedlist.h b/src/tools/qdoc/openedlist.h index 7d40add8b1..cf7624b8e3 100644 --- a/src/tools/qdoc/openedlist.h +++ b/src/tools/qdoc/openedlist.h @@ -49,11 +49,14 @@ #include <qstring.h> #include "location.h" +#include "tr.h" QT_BEGIN_NAMESPACE class OpenedList { + Q_DECLARE_TR_FUNCTIONS(QDoc::OpenedList) + public: enum Style { Bullet, Tag, Value, Numeric, UpperAlpha, LowerAlpha, UpperRoman, LowerRoman }; diff --git a/src/tools/qdoc/puredocparser.h b/src/tools/qdoc/puredocparser.h index f25f777733..0174af7a4e 100644 --- a/src/tools/qdoc/puredocparser.h +++ b/src/tools/qdoc/puredocparser.h @@ -60,6 +60,8 @@ class Tree; class PureDocParser : public CppCodeParser { + Q_DECLARE_TR_FUNCTIONS(QDoc::PureDocParser) + public: PureDocParser(); virtual ~PureDocParser(); diff --git a/src/tools/qdoc/qdocdatabase.h b/src/tools/qdoc/qdocdatabase.h index 21f955566f..857fd301bb 100644 --- a/src/tools/qdoc/qdocdatabase.h +++ b/src/tools/qdoc/qdocdatabase.h @@ -82,6 +82,8 @@ typedef QMultiMap<QString, TargetRec> TargetRecMultiMap; class QDocDatabase { + Q_DECLARE_TR_FUNCTIONS(QDoc::QDocDatabase) + public: static QDocDatabase* qdocDB(); static void destroyQdocDB(); diff --git a/src/tools/qdoc/qmlcodemarker.h b/src/tools/qdoc/qmlcodemarker.h index 7e801d083e..bc2321e076 100644 --- a/src/tools/qdoc/qmlcodemarker.h +++ b/src/tools/qdoc/qmlcodemarker.h @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE class QmlCodeMarker : public CppCodeMarker { + Q_DECLARE_TR_FUNCTIONS(QDoc::QmlCodeMarker) + public: QmlCodeMarker(); ~QmlCodeMarker(); diff --git a/src/tools/qdoc/qmlcodeparser.h b/src/tools/qdoc/qmlcodeparser.h index 5a33238584..5bdcfbfbbf 100644 --- a/src/tools/qdoc/qmlcodeparser.h +++ b/src/tools/qdoc/qmlcodeparser.h @@ -62,6 +62,8 @@ class Tree; class QmlCodeParser : public CodeParser { + Q_DECLARE_TR_FUNCTIONS(QDoc::QmlCodeParser) + public: QmlCodeParser(); virtual ~QmlCodeParser(); diff --git a/src/tools/qdoc/qmlparser/qqmljslexer_p.h b/src/tools/qdoc/qmlparser/qqmljslexer_p.h index f22325ebf9..cb6ff6bcdf 100644 --- a/src/tools/qdoc/qmlparser/qqmljslexer_p.h +++ b/src/tools/qdoc/qmlparser/qqmljslexer_p.h @@ -55,6 +55,7 @@ #include "qqmljsglobal_p.h" #include "qqmljsgrammar_p.h" +#include "tr.h" #include <qstring.h> QT_QML_BEGIN_NAMESPACE @@ -87,6 +88,8 @@ public: class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar { + Q_DECLARE_TR_FUNCTIONS(QDoc::QQmlJS::Lexer) + public: enum { T_ABSTRACT = T_RESERVED_WORD, diff --git a/src/tools/qdoc/qmlparser/qqmljsparser.cpp b/src/tools/qdoc/qmlparser/qqmljsparser.cpp index 104aa3d557..b7f571aa62 100644 --- a/src/tools/qdoc/qmlparser/qqmljsparser.cpp +++ b/src/tools/qdoc/qmlparser/qqmljsparser.cpp @@ -40,12 +40,6 @@ ****************************************************************************/ #include <qdebug.h> -#ifdef QT_BOOTSTRAPPED -#define tr(x, y) QString(QLatin1String(y)) -#else -#include <qcoreapplication.h> -#define tr(x, y) QCoreApplication::translate(x, y) -#endif #include <string.h> diff --git a/src/tools/qdoc/qmlparser/qqmljsparser_p.h b/src/tools/qdoc/qmlparser/qqmljsparser_p.h index e59ef67ffd..9fe7428bc2 100644 --- a/src/tools/qdoc/qmlparser/qqmljsparser_p.h +++ b/src/tools/qdoc/qmlparser/qqmljsparser_p.h @@ -75,6 +75,8 @@ class Engine; class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar { + Q_DECLARE_TR_FUNCTIONS(QDoc::QQmlJS::Parser) + public: union Value { int ival; diff --git a/src/tools/qdoc/qmlvisitor.h b/src/tools/qdoc/qmlvisitor.h index acf34ab95c..172aca579a 100644 --- a/src/tools/qdoc/qmlvisitor.h +++ b/src/tools/qdoc/qmlvisitor.h @@ -66,6 +66,8 @@ struct QmlPropArgs class QmlDocVisitor : public QQmlJS::AST::Visitor { + Q_DECLARE_TR_FUNCTIONS(QDoc::QmlDocVisitor) + public: QmlDocVisitor(const QString &filePath, const QString &code, diff --git a/src/tools/qdoc/quoter.h b/src/tools/qdoc/quoter.h index 9f2e3f7852..223fdd96b3 100644 --- a/src/tools/qdoc/quoter.h +++ b/src/tools/qdoc/quoter.h @@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE class Quoter { + Q_DECLARE_TR_FUNCTIONS(QDoc::Quoter) + public: Quoter(); diff --git a/src/tools/qdoc/separator.cpp b/src/tools/qdoc/separator.cpp index b9320449c6..2403fb15c8 100644 --- a/src/tools/qdoc/separator.cpp +++ b/src/tools/qdoc/separator.cpp @@ -51,14 +51,14 @@ QT_BEGIN_NAMESPACE QString separator(int index, int count) { if (index == count - 1) - return tr(".", "terminator"); + return QCoreApplication::translate("QDoc", ".", "terminator"); if (count == 2) - return tr(" and ", "separator when N = 2"); + return QCoreApplication::translate("QDoc", " and ", "separator when N = 2"); if (index == 0) - return tr(", ", "first separator when N > 2"); + return QCoreApplication::translate("QDoc", ", ", "first separator when N > 2"); if (index < count - 2) - return tr(", ", "general separator when N > 2"); - return tr(", and ", "last separator when N > 2"); + return QCoreApplication::translate("QDoc", ", ", "general separator when N > 2"); + return QCoreApplication::translate("QDoc", ", and ", "last separator when N > 2"); } QString comma(int index, int count) @@ -66,12 +66,12 @@ QString comma(int index, int count) if (index == count - 1) return QString(); if (count == 2) - return tr(" and ", "separator when N = 2"); + return QCoreApplication::translate("QDoc", " and ", "separator when N = 2"); if (index == 0) - return tr(", ", "first separator when N > 2"); + return QCoreApplication::translate("QDoc", ", ", "first separator when N > 2"); if (index < count - 2) - return tr(", ", "general separator when N > 2"); - return tr(", and ", "last separator when N > 2"); + return QCoreApplication::translate("QDoc", ", ", "general separator when N > 2"); + return QCoreApplication::translate("QDoc", ", and ", "last separator when N > 2"); } QT_END_NAMESPACE diff --git a/src/tools/qdoc/tokenizer.h b/src/tools/qdoc/tokenizer.h index ae67a9b8a9..4e2c622f3c 100644 --- a/src/tools/qdoc/tokenizer.h +++ b/src/tools/qdoc/tokenizer.h @@ -96,6 +96,8 @@ enum { Tok_Eoi, Tok_Ampersand, Tok_Aster, Tok_Caret, Tok_LeftParen, class Tokenizer { + Q_DECLARE_TR_FUNCTIONS(QDoc::Tokenizer) + public: Tokenizer(const Location& loc, const QByteArray &in); Tokenizer(const Location& loc, QFile &file); diff --git a/src/tools/qdoc/tr.h b/src/tools/qdoc/tr.h index 686b9171ab..36b0c47fef 100644 --- a/src/tools/qdoc/tr.h +++ b/src/tools/qdoc/tr.h @@ -46,26 +46,36 @@ #ifndef TR_H #define TR_H -#ifndef QT_BOOTSTRAPPED -# include "qcoreapplication.h" +#include <qglobal.h> + +#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_TRANSLATION) +# define TRANSLATE_QDOC #endif #include <qstring.h> +#ifdef TRANSLATE_QDOC +# include <qcoreapplication.h> +#endif QT_BEGIN_NAMESPACE -#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_TRANSLATION) +#ifndef TRANSLATE_QDOC + +#define Q_DECLARE_TR_FUNCTIONS(context) + inline QString tr(const char *sourceText, const char *comment = 0) { Q_UNUSED(comment); return QString( QLatin1String(sourceText) ); } -#else -inline QString tr(const char *sourceText, const char *comment = 0) + +struct QCoreApplication { - return QCoreApplication::instance()->translate("", sourceText, comment); -} -#endif + static inline QString translate(const char * /* context */ , const char *sourceText, const char * /* disambiguation */ = 0) + { return QLatin1String(sourceText); } +}; + +#endif // !TRANSLATE_QDOC QT_END_NAMESPACE |