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>bb10
parent
5221ae5f42
commit
41dfd254c3
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ class QDocDatabase;
|
|||
|
||||
class CodeParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::CodeParser)
|
||||
|
||||
public:
|
||||
CodeParser();
|
||||
virtual ~CodeParser();
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ void MetaStackEntry::close()
|
|||
*/
|
||||
class MetaStack : private QStack<MetaStackEntry>
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::MetaStack)
|
||||
|
||||
public:
|
||||
MetaStack();
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ typedef QMap<QString, QStringListPair> QStringListPairMap;
|
|||
|
||||
class Config
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::Config)
|
||||
|
||||
public:
|
||||
Config(const QString& programName);
|
||||
~Config();
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class CppCodeMarker : public CodeMarker
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::CppCodeMarker)
|
||||
|
||||
public:
|
||||
CppCodeMarker();
|
||||
~CppCodeMarker();
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ class Tokenizer;
|
|||
|
||||
class CppCodeParser : public CodeParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::CppCodeParser)
|
||||
|
||||
public:
|
||||
CppCodeParser();
|
||||
~CppCodeParser();
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ typedef QMap<QString, GuidMap*> GuidMaps;
|
|||
|
||||
class DitaXmlGenerator : public Generator
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::DitaXmlGenerator)
|
||||
|
||||
public:
|
||||
enum SinceType {
|
||||
Namespace,
|
||||
|
|
|
|||
|
|
@ -439,6 +439,8 @@ bool DocPrivate::isEnumDocSimplifiable() const
|
|||
|
||||
class DocParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::DocParser)
|
||||
|
||||
public:
|
||||
void parse(const QString &source,
|
||||
DocPrivate *docPrivate,
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ public:
|
|||
|
||||
class Doc
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::Doc)
|
||||
|
||||
public:
|
||||
// the order is important
|
||||
enum Sections {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ class QDocDatabase;
|
|||
|
||||
class Generator
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::Generator)
|
||||
|
||||
public:
|
||||
enum Passes { Both, Prepare, Generate };
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ struct HelpProject
|
|||
|
||||
class HelpProjectWriter
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::HelpProjectWriter)
|
||||
|
||||
public:
|
||||
HelpProjectWriter(const Config &config,
|
||||
const QString &defaultFileName,
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ class HelpProjectWriter;
|
|||
|
||||
class HtmlGenerator : public Generator
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::HtmlGenerator)
|
||||
|
||||
public:
|
||||
enum SinceType {
|
||||
Namespace,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class JsCodeMarker : public QmlCodeMarker
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::JsCodeMarker)
|
||||
|
||||
public:
|
||||
JsCodeMarker();
|
||||
~JsCodeMarker();
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ class QRegExp;
|
|||
|
||||
class Location
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::Location)
|
||||
|
||||
public:
|
||||
Location();
|
||||
Location(const QString& filePath);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ class Tree;
|
|||
|
||||
class PureDocParser : public CppCodeParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::PureDocParser)
|
||||
|
||||
public:
|
||||
PureDocParser();
|
||||
virtual ~PureDocParser();
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ typedef QMultiMap<QString, TargetRec> TargetRecMultiMap;
|
|||
|
||||
class QDocDatabase
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::QDocDatabase)
|
||||
|
||||
public:
|
||||
static QDocDatabase* qdocDB();
|
||||
static void destroyQdocDB();
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class QmlCodeMarker : public CppCodeMarker
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::QmlCodeMarker)
|
||||
|
||||
public:
|
||||
QmlCodeMarker();
|
||||
~QmlCodeMarker();
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ class Tree;
|
|||
|
||||
class QmlCodeParser : public CodeParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::QmlCodeParser)
|
||||
|
||||
public:
|
||||
QmlCodeParser();
|
||||
virtual ~QmlCodeParser();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class Quoter
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDoc::Quoter)
|
||||
|
||||
public:
|
||||
Quoter();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue