diff options
author | ck <qt-info@nokia.com> | 2010-02-02 10:45:04 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2010-02-02 10:45:04 (GMT) |
commit | f063786144477336c462b06642fc3725c060311d (patch) | |
tree | b057ac404935d494f39fb3b1004fbbe40284b084 /tools | |
parent | cf3eddb9c917aa5180a961c2bc9700e47a5f8434 (diff) | |
download | Qt-f063786144477336c462b06642fc3725c060311d.zip Qt-f063786144477336c462b06642fc3725c060311d.tar.gz Qt-f063786144477336c462b06642fc3725c060311d.tar.bz2 |
Assistant: Give meaningful context to translations.
Reviewed-by: kh1
Instigated-by: Friedemann Kleint
Diffstat (limited to 'tools')
-rw-r--r-- | tools/assistant/lib/qhelp_global.cpp | 3 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpprojectdata.cpp | 47 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/cmdlineparser.cpp | 6 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/helpviewer.cpp | 5 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/main.cpp | 40 | ||||
-rw-r--r-- | tools/assistant/tools/qcollectiongenerator/main.cpp | 21 | ||||
-rw-r--r-- | tools/assistant/tools/qhelpgenerator/main.cpp | 11 |
7 files changed, 85 insertions, 48 deletions
diff --git a/tools/assistant/lib/qhelp_global.cpp b/tools/assistant/lib/qhelp_global.cpp index 8e96b55..d8a94d3 100644 --- a/tools/assistant/lib/qhelp_global.cpp +++ b/tools/assistant/lib/qhelp_global.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include <QtCore/QCoreApplication> #include <QtCore/QRegExp> #include <QtCore/QMutexLocker> #include <QtGui/QTextDocument> @@ -60,7 +61,7 @@ QString QHelpGlobal::uniquifyConnectionName(const QString &name, void *pointer) QString QHelpGlobal::documentTitle(const QString &content) { - QString title = QObject::tr("Untitled"); + QString title = QCoreApplication::translate("QHelp", "Untitled"); if (!content.isEmpty()) { int start = content.indexOf(QLatin1String("<title>"), 0, Qt::CaseInsensitive) + 7; int end = content.indexOf(QLatin1String("</title>"), 0, Qt::CaseInsensitive); diff --git a/tools/assistant/lib/qhelpprojectdata.cpp b/tools/assistant/lib/qhelpprojectdata.cpp index 869a446..83491a0 100644 --- a/tools/assistant/lib/qhelpprojectdata.cpp +++ b/tools/assistant/lib/qhelpprojectdata.cpp @@ -41,6 +41,7 @@ #include "qhelpprojectdata_p.h" +#include <QtCore/QCoreApplication> #include <QtCore/QDir> #include <QtCore/QFileInfo> #include <QtCore/QStack> @@ -82,7 +83,7 @@ private: void QHelpProjectDataPrivate::raiseUnknownTokenError() { - raiseError(QObject::tr("Unknown token.")); + raiseError(QCoreApplication::translate("QHelpProject", "Unknown token.")); } void QHelpProjectDataPrivate::readData(const QByteArray &contents) @@ -95,12 +96,14 @@ void QHelpProjectDataPrivate::readData(const QByteArray &contents) && attributes().value(QLatin1String("version")) == QLatin1String("1.0")) readProject(); else - raiseError(QObject::tr("Unknown token. Expected \"QtHelpProject\"!")); + raiseError(QCoreApplication::translate("QHelpProject", + "Unknown token. Expected \"QtHelpProject\"!")); } } if (hasError()) { - raiseError(QObject::tr("Error in line %1: %2").arg(lineNumber()) + raiseError(QCoreApplication::translate("QHelpProject", + "Error in line %1: %2").arg(lineNumber()) .arg(errorString())); } } @@ -113,11 +116,15 @@ void QHelpProjectDataPrivate::readProject() if (name() == QLatin1String("virtualFolder")) { virtualFolder = readElementText(); if (virtualFolder.contains(QLatin1String("/"))) - raiseError(QObject::tr("A virtual folder must not contain a \'/\' character!")); + raiseError(QCoreApplication::translate("QHelpProject", + "A virtual folder must not contain " + "a \'/\' character!")); } else if (name() == QLatin1String("namespace")) { namespaceName = readElementText(); if (namespaceName.contains(QLatin1String("/"))) - raiseError(QObject::tr("A namespace must not contain a \'/\' character!")); + raiseError(QCoreApplication::translate("QHelpProject", + "A namespace must not contain a " + "\'/\' character!")); } else if (name() == QLatin1String("customFilter")) { readCustomFilter(); } else if (name() == QLatin1String("filterSection")) { @@ -125,17 +132,21 @@ void QHelpProjectDataPrivate::readProject() } else if (name() == QLatin1String("metaData")) { QString n = attributes().value(QLatin1String("name")).toString(); if (!metaData.contains(n)) - metaData[n] = attributes().value(QLatin1String("value")).toString(); + metaData[n] + = attributes().value(QLatin1String("value")).toString(); else - metaData.insert(n, attributes().value(QLatin1String("value")).toString()); + metaData.insert(n, attributes(). + value(QLatin1String("value")).toString()); } else { raiseUnknownTokenError(); } } else if (isEndElement() && name() == QLatin1String("QtHelpProject")) { if (namespaceName.isEmpty()) - raiseError(QObject::tr("Missing namespace in QtHelpProject.")); + raiseError(QCoreApplication::translate("QHelpProject", + "Missing namespace in QtHelpProject.")); else if (virtualFolder.isEmpty()) - raiseError(QObject::tr("Missing virtual folder in QtHelpProject")); + raiseError(QCoreApplication::translate("QHelpProject", + "Missing virtual folder in QtHelpProject")); break; } } @@ -223,12 +234,14 @@ void QHelpProjectDataPrivate::readKeywords() if (attributes().value(QLatin1String("ref")).toString().isEmpty() || (attributes().value(QLatin1String("name")).toString().isEmpty() && attributes().value(QLatin1String("id")).toString().isEmpty())) - raiseError(QObject::tr("Missing attribute in keyword at line %1.") - .arg(lineNumber())); - filterSectionList.last().addIndex( - QHelpDataIndexItem(attributes().value(QLatin1String("name")).toString(), - attributes().value(QLatin1String("id")).toString(), - attributes().value(QLatin1String("ref")).toString())); + raiseError(QCoreApplication::translate("QHelpProject", + "Missing attribute in keyword at line %1.") + .arg(lineNumber())); + filterSectionList.last() + .addIndex(QHelpDataIndexItem(attributes(). + value(QLatin1String("name")).toString(), + attributes().value(QLatin1String("id")).toString(), + attributes().value(QLatin1String("ref")).toString())); } else { raiseUnknownTokenError(); } @@ -346,8 +359,8 @@ bool QHelpProjectData::readData(const QString &fileName) d->rootPath = QFileInfo(fileName).absolutePath(); QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - d->errorMsg = QObject::tr("The input file %1 could not be opened!") - .arg(fileName); + d->errorMsg = QCoreApplication::translate("QHelpProject", + "The input file %1 could not be opened!").arg(fileName); return false; } diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp index b3ba93c..b063830 100644 --- a/tools/assistant/tools/assistant/cmdlineparser.cpp +++ b/tools/assistant/tools/assistant/cmdlineparser.cpp @@ -278,10 +278,12 @@ void CmdLineParser::showMessage(const QString &msg, bool error) return; #ifdef Q_OS_WIN QString s = QLatin1String("<pre>") + msg + QLatin1String("</pre>"); + const QString &message + = QCoreApplication::translate("Assistant", "Qt Assistant"), s); if (error) - QMessageBox::critical(0, QObject::tr("Qt Assistant"), s); + QMessageBox::critical(0, message); else - QMessageBox::information(0, QObject::tr("Qt Assistant"), s); + QMessageBox::information(0, message); #else fprintf(error ? stderr : stdout, "%s\n", qPrintable(msg)); #endif diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index bd75f3a..00504e7 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -67,8 +67,9 @@ QT_BEGIN_NAMESPACE namespace { const QString PageNotFoundMessage = - QObject::tr("<title>Error 404...</title><div align=\"center\"><br><br>" - "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>"); + QCoreApplication::translate("HelpViewer", + "<title>Error 404...</title><div align=\"center\"><br><br>" + "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>"); } #if !defined(QT_NO_WEBKIT) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 434a211..cc76f81 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -174,8 +174,9 @@ bool synchronizeDocs(QHelpEngineCore &collection, if (!cachedDocs.contains(doc)) { const QString &docFile = collection.documentationFileName(doc); if (!cachedCollection.registerDocumentation(docFile)) { - cmd.showMessage(QObject::tr("Error registering documentation file '%1': %2"). - arg(docFile).arg(cachedCollection.error()), true); + cmd.showMessage(QCoreApplication::translate("Assistant", + "Error registering documentation file '%1': %2"). + arg(docFile).arg(cachedCollection.error()), true); return false; } } @@ -212,7 +213,8 @@ bool rebuildSearchIndex(QCoreApplication &app, const QString &collectionFile, TRACE_OBJ QHelpEngine engine(collectionFile); if (!engine.setupData()) { - cmd.showMessage(QObject::tr("Error: %1").arg(engine.error()), true); + cmd.showMessage(QCoreApplication::translate("Assistant", "Error: %1") + .arg(engine.error()), true); return false; } @@ -250,13 +252,14 @@ bool registerDocumentation(QHelpEngineCore &collection, CmdLineParser &cmd, { TRACE_OBJ if (!collection.registerDocumentation(cmd.helpFile())) { - cmd.showMessage( - QObject::tr("Could not register documentation file\n%1\n\nReason:\n%2") - .arg(cmd.helpFile()).arg(collection.error()), true); + cmd.showMessage(QCoreApplication::translate("Assistant", + "Could not register documentation file\n%1\n\nReason:\n%2") + .arg(cmd.helpFile()).arg(collection.error()), true); return false; } if (printSuccess) - cmd.showMessage(QObject::tr("Documentation successfully registered."), + cmd.showMessage(QCoreApplication::translate("Assistant", + "Documentation successfully registered."), false); CollectionConfiguration::updateLastRegisterTime(collection); return true; @@ -267,14 +270,16 @@ bool unregisterDocumentation(QHelpEngineCore &collection, { TRACE_OBJ if (!collection.unregisterDocumentation(namespaceName)) { - cmd.showMessage(QObject::tr("Could not unregister documentation" - " file\n%1\n\nReason:\n%2"). + cmd.showMessage(QCoreApplication::translate("Assistant", + "Could not unregister documentation" + " file\n%1\n\nReason:\n%2"). arg(cmd.helpFile()).arg(collection.error()), true); return false; } updateLastPagesOnUnregister(collection, namespaceName); if (printSuccess) - cmd.showMessage(QObject::tr("Documentation successfully unregistered."), + cmd.showMessage(QCoreApplication::translate("Assistant", + "Documentation successfully unregistered."), false); return true; } @@ -328,7 +333,8 @@ int main(int argc, char *argv[]) if (collectionFileGiven) { collection.reset(new QHelpEngineCore(collectionFile)); if (!collection->setupData()) { - cmd.showMessage(QObject::tr("Error reading collection file '%1': %2."). + cmd.showMessage(QCoreApplication::translate("Assistant", + "Error reading collection file '%1': %2."). arg(collectionFile).arg(collection->error()), true); return EXIT_FAILURE; } @@ -338,13 +344,15 @@ int main(int argc, char *argv[]) : MainWindow::defaultHelpCollectionFileName(); if (collectionFileGiven && !QFileInfo(cachedCollectionFile).exists() && !collection->copyCollectionFile(cachedCollectionFile)) { - cmd.showMessage(QObject::tr("Error creating collection file '%1': %2."). + cmd.showMessage(QCoreApplication::translate("Assistant", + "Error creating collection file '%1': %2."). arg(cachedCollectionFile).arg(collection->error()), true); return EXIT_FAILURE; } QHelpEngineCore cachedCollection(cachedCollectionFile); if (!cachedCollection.setupData()) { - cmd.showMessage(QObject::tr("Error reading collection file '%1': %2"). + cmd.showMessage(QCoreApplication::translate("Assistant", + "Error reading collection file '%1': %2"). arg(cachedCollectionFile). arg(cachedCollection.error()), true); return EXIT_FAILURE; @@ -365,7 +373,8 @@ int main(int argc, char *argv[]) const QString &namespaceName = QHelpEngineCore::namespaceName(cmd.helpFile()); if (cmd.registerRequest() == CmdLineParser::Register) { - if (collectionFileGiven && !registerDocumentation(*collection, cmd, true)) + if (collectionFileGiven + && !registerDocumentation(*collection, cmd, true)) return EXIT_FAILURE; if (!cachedDocs.contains(namespaceName) && !registerDocumentation(cachedCollection, cmd, !collectionFileGiven)) @@ -395,7 +404,8 @@ int main(int argc, char *argv[]) } if (!QSqlDatabase::isDriverAvailable(QLatin1String("QSQLITE"))) { - cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"), + cmd.showMessage(QCoreApplication::translate("Assistant", + "Cannot load sqlite database driver!"), true); return EXIT_FAILURE; } diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp index f75d891..7fcb4e1 100644 --- a/tools/assistant/tools/qcollectiongenerator/main.cpp +++ b/tools/assistant/tools/qcollectiongenerator/main.cpp @@ -45,6 +45,7 @@ #include <private/qhelpgenerator_p.h> #include <private/qhelpprojectdata_p.h> +#include <QtCore/QCoreApplication> #include <QtCore/QDir> #include <QtCore/QMap> #include <QtCore/QFileInfo> @@ -122,7 +123,8 @@ private: void CollectionConfigReader::raiseErrorWithLine() { - raiseError(QObject::tr("Unknown token at line %1.") + raiseError(QCoreApplication::translate("QCollectionGenerator", + "Unknown token at line %1.") .arg(lineNumber())); } @@ -142,8 +144,10 @@ void CollectionConfigReader::readData(const QByteArray &contents) && attributes().value(QLatin1String("version")) == QLatin1String("1.0")) readConfig(); else - raiseError(QObject::tr("Unknown token at line %1. Expected \"QtHelpCollectionProject\"!") - .arg(lineNumber())); + raiseError(QCoreApplication::translate("QCollectionGenerator", + "Unknown token at line %1. " + "Expected \"QtHelpCollectionProject\"!") + .arg(lineNumber())); } } } @@ -353,7 +357,8 @@ int main(int argc, char *argv[]) QFileInfo fi(QString::fromLocal8Bit(argv[i])); collectionFile = fi.absoluteFilePath(); } else { - error = QObject::tr("Missing output file name!"); + error = QCoreApplication::translate("QCollectionGenerator", + "Missing output file name!"); } } else if (arg == QLatin1String("-h")) { showHelp = true; @@ -367,14 +372,16 @@ int main(int argc, char *argv[]) } if (showVersion) { - fprintf(stdout, "Qt Collection Generator version 1.0 (Qt %s)\n", QT_VERSION_STR); + fprintf(stdout, "Qt Collection Generator version 1.0 (Qt %s)\n", + QT_VERSION_STR); return 0; } if (configFile.isEmpty() && !showHelp) - error = QObject::tr("Missing collection config file!"); + error = QCoreApplication::translate("QCollectionGenerator", + "Missing collection config file!"); - QString help = QObject::tr("\nUsage:\n\n" + QString help = QCoreApplication::translate("QCollectionGenerator", "\nUsage:\n\n" "qcollectiongenerator <collection-config-file> [options]\n\n" " -o <collection-file> Generates a collection file\n" " called <collection-file>. If\n" diff --git a/tools/assistant/tools/qhelpgenerator/main.cpp b/tools/assistant/tools/qhelpgenerator/main.cpp index 00a0a3d..a309f42 100644 --- a/tools/assistant/tools/qhelpgenerator/main.cpp +++ b/tools/assistant/tools/qhelpgenerator/main.cpp @@ -67,7 +67,8 @@ int main(int argc, char *argv[]) QFileInfo fi(QString::fromLocal8Bit(argv[i])); compressedFile = fi.absoluteFilePath(); } else { - error = QObject::tr("Missing output file name!"); + error = QCoreApplication::translate("QHelpGenerator", + "Missing output file name!"); } } else if (arg == QLatin1String("-v")) { showVersion = true; @@ -83,14 +84,16 @@ int main(int argc, char *argv[]) } if (showVersion) { - fprintf(stdout, "Qt Help Generator version 1.0 (Qt %s)\n", QT_VERSION_STR); + fprintf(stdout, "Qt Help Generator version 1.0 (Qt %s)\n", + QT_VERSION_STR); return 0; } if (projectFile.isEmpty() && !showHelp) - error = QObject::tr("Missing Qt help project file!"); + error = QCoreApplication::translate("QHelpGenerator", + "Missing Qt help project file!"); - QString help = QObject::tr("\nUsage:\n\n" + QString help = QCoreApplication::translate("QHelpGenerator", "\nUsage:\n\n" "qhelpgenerator <help-project-file> [options]\n\n" " -o <compressed-file> Generates a Qt compressed help\n" " file called <compressed-file>.\n" |