summaryrefslogtreecommitdiffstats
path: root/tools/linguist/lrelease/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/linguist/lrelease/main.cpp')
-rw-r--r--tools/linguist/lrelease/main.cpp61
1 files changed, 53 insertions, 8 deletions
diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp
index 96b1926..f9e08a0 100644
--- a/tools/linguist/lrelease/main.cpp
+++ b/tools/linguist/lrelease/main.cpp
@@ -40,7 +40,9 @@
****************************************************************************/
#include "translator.h"
-#include "profileevaluator.h"
+
+#include <profileparser.h>
+#include <profileevaluator.h>
#ifndef QT_BOOTSTRAPPED
#include <QtCore/QCoreApplication>
@@ -58,6 +60,8 @@
QT_USE_NAMESPACE
#ifdef QT_BOOTSTRAPPED
+static QString binDir;
+
static void initBinaryDir(
#ifndef Q_OS_WIN
const char *argv0
@@ -185,6 +189,40 @@ static bool releaseTsFile(const QString& tsFileName,
return releaseTranslator(tor, qmFileName, cd, removeIdentical);
}
+static void print(const QString &fileName, int lineNo, const QString &msg)
+{
+ if (lineNo)
+ printErr(QString::fromLatin1("%2(%1): %3").arg(lineNo).arg(fileName, msg));
+ else
+ printErr(msg);
+}
+
+class ParseHandler : public ProFileParserHandler {
+public:
+ virtual void parseError(const QString &fileName, int lineNo, const QString &msg)
+ { if (verbose) print(fileName, lineNo, msg); }
+
+ bool verbose;
+};
+
+class EvalHandler : public ProFileEvaluatorHandler {
+public:
+ virtual void configError(const QString &msg)
+ { printErr(msg); }
+ virtual void evalError(const QString &fileName, int lineNo, const QString &msg)
+ { if (verbose) print(fileName, lineNo, msg); }
+ virtual void fileMessage(const QString &msg)
+ { printErr(msg); }
+
+ virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {}
+ virtual void doneWithEval(ProFile *) {}
+
+ bool verbose;
+};
+
+static ParseHandler parseHandler;
+static EvalHandler evalHandler;
+
int main(int argc, char **argv)
{
#ifdef QT_BOOTSTRAPPED
@@ -272,23 +310,32 @@ int main(int argc, char **argv)
if (inputFile.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive)
|| inputFile.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) {
QFileInfo fi(inputFile);
- ProFile pro(fi.absoluteFilePath());
- ProFileEvaluator visitor;
- visitor.setVerbose(cd.isVerbose());
+ parseHandler.verbose = evalHandler.verbose = cd.isVerbose();
+ ProFileOption option;
+#ifdef QT_BOOTSTRAPPED
+ option.initProperties(binDir + QLatin1String("/qmake"));
+#else
+ option.initProperties(app.applicationDirPath() + QLatin1String("/qmake"));
+#endif
+ ProFileParser parser(0, &parseHandler);
+ ProFileEvaluator visitor(&option, &parser, &evalHandler);
- if (!visitor.queryProFile(&pro)) {
+ ProFile *pro;
+ if (!(pro = parser.parsedProFile(QDir::cleanPath(fi.absoluteFilePath())))) {
printErr(LR::tr(
"lrelease error: cannot read project file '%1'.\n")
.arg(inputFile));
continue;
}
- if (!visitor.accept(&pro)) {
+ if (!visitor.accept(pro)) {
printErr(LR::tr(
"lrelease error: cannot process project file '%1'.\n")
.arg(inputFile));
+ pro->deref();
continue;
}
+ pro->deref();
QStringList translations = visitor.values(QLatin1String("TRANSLATIONS"));
if (translations.isEmpty()) {
@@ -324,8 +371,6 @@ int main(int argc, char **argv)
# include <windows.h>
#endif
-static QString binDir;
-
static void initBinaryDir(
#ifndef Q_OS_WIN
const char *_argv0