Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/linguist/lrelease/main.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4141
    4242#include "translator.h"
    43 #include "proreader.h"
     43#include "profileevaluator.h"
    4444
    4545#ifndef QT_BOOTSTRAPPED
     
    112112            printOut(cd.error());
    113113    }
     114    cd.clearErrors();
    114115    return ok;
    115116}
     
    142143        qWarning("lrelease error: cannot save '%s': %s\n",
    143144                 qPrintable(qmFileName), qPrintable(cd.error()));
    144         return false;
    145145    } else if (!cd.errors().isEmpty()) {
    146146        printOut(cd.error());
    147147    }
    148     return true;
     148    cd.clearErrors();
     149    return ok;
    149150}
    150151
     
    246247        if (inputFile.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive)
    247248            || inputFile.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) {
    248             QHash<QByteArray, QStringList> varMap;
    249             bool ok = evaluateProFile(inputFile, cd.isVerbose(), &varMap);
    250             if (ok) {
    251                 QStringList translations = varMap.value("TRANSLATIONS");
    252                 if (translations.isEmpty()) {
    253                     qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in"
    254                              " project file '%s'\n",
    255                              qPrintable(inputFile));
    256                 } else {
    257                     foreach (const QString &trans, translations)
    258                         if (!releaseTsFile(trans, cd, removeIdentical))
    259                             return 1;
    260                 }
     249            QFileInfo fi(inputFile);
     250            ProFile pro(fi.absoluteFilePath());
     251
     252            ProFileEvaluator visitor;
     253            visitor.setVerbose(cd.isVerbose());
     254
     255            if (!visitor.queryProFile(&pro)) {
     256                qWarning("lrelease error: cannot read project file '%s'.", qPrintable(inputFile));
     257                continue;
     258            }
     259            if (!visitor.accept(&pro)) {
     260                qWarning("lrelease error: cannot process project file '%s'.", qPrintable(inputFile));
     261                continue;
     262            }
     263
     264            QStringList translations = visitor.values(QLatin1String("TRANSLATIONS"));
     265            if (translations.isEmpty()) {
     266                qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in"
     267                         " project file '%s'\n",
     268                         qPrintable(inputFile));
    261269            } else {
    262                 qWarning("error: lrelease encountered project file functionality that is currently not supported.\n"
    263                     "You might want to consider using TS files as input instead of a project file.\n"
    264                     "Try the following syntax:\n"
    265                     "    lrelease [options] ts-files [-qm qm-file]\n");
     270                QDir proDir(fi.absolutePath());
     271                foreach (const QString &trans, translations)
     272                    if (!releaseTsFile(QFileInfo(proDir, trans).filePath(), cd, removeIdentical))
     273                        return 1;
    266274            }
    267275        } else {
Note: See TracChangeset for help on using the changeset viewer.