tools/linguist/lupdate/main.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    52 #include <QtCore/QFileInfo>
    52 #include <QtCore/QFileInfo>
    53 #include <QtCore/QString>
    53 #include <QtCore/QString>
    54 #include <QtCore/QStringList>
    54 #include <QtCore/QStringList>
    55 #include <QtCore/QTextCodec>
    55 #include <QtCore/QTextCodec>
    56 
    56 
       
    57 #include <iostream>
       
    58 
    57 static QString m_defaultExtensions;
    59 static QString m_defaultExtensions;
       
    60 
       
    61 static void printErr(const QString & out)
       
    62 {
       
    63     qWarning("%s", qPrintable(out));
       
    64 }
    58 
    65 
    59 static void printOut(const QString & out)
    66 static void printOut(const QString & out)
    60 {
    67 {
    61     qWarning("%s", qPrintable(out));
    68     std::cerr << qPrintable(out);
    62 }
    69 }
    63 
    70 
    64 static void recursiveFileInfoList(const QDir &dir,
    71 static void recursiveFileInfoList(const QDir &dir,
    65     const QSet<QString> &nameFilters, QDir::Filters filter,
    72     const QSet<QString> &nameFilters, QDir::Filters filter,
    66     QFileInfoList *fileinfolist)
    73     QFileInfoList *fileinfolist)
   135         ConversionData cd;
   142         ConversionData cd;
   136         Translator tor;
   143         Translator tor;
   137         cd.m_sortContexts = !(options & NoSort);
   144         cd.m_sortContexts = !(options & NoSort);
   138         if (QFile(fileName).exists()) {
   145         if (QFile(fileName).exists()) {
   139             if (!tor.load(fileName, cd, QLatin1String("auto"))) {
   146             if (!tor.load(fileName, cd, QLatin1String("auto"))) {
   140                 printOut(cd.error());
   147                 printErr(cd.error());
   141                 *fail = true;
   148                 *fail = true;
   142                 continue;
   149                 continue;
   143             }
   150             }
   144             tor.resolveDuplicates();
   151             tor.resolveDuplicates();
   145             cd.clearErrors();
   152             cd.clearErrors();
   195             out.stripObsoleteMessages();
   202             out.stripObsoleteMessages();
   196         out.stripEmptyContexts();
   203         out.stripEmptyContexts();
   197 
   204 
   198         out.normalizeTranslations(cd);
   205         out.normalizeTranslations(cd);
   199         if (!cd.errors().isEmpty()) {
   206         if (!cd.errors().isEmpty()) {
   200             printOut(cd.error());
   207             printErr(cd.error());
   201             cd.clearErrors();
   208             cd.clearErrors();
   202         }
   209         }
   203         if (!out.save(fileName, cd, QLatin1String("auto"))) {
   210         if (!out.save(fileName, cd, QLatin1String("auto"))) {
   204             printOut(cd.error());
   211             printErr(cd.error());
   205             *fail = true;
   212             *fail = true;
   206         }
   213         }
   207     }
   214     }
   208 }
   215 }
   209 
   216 
   492 
   499 
   493             QStringList tmp = variables.value("CODECFORTR");
   500             QStringList tmp = variables.value("CODECFORTR");
   494             if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
   501             if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
   495                 codecForTr = tmp.first().toLatin1();
   502                 codecForTr = tmp.first().toLatin1();
   496                 fetchedTor.setCodecName(codecForTr);
   503                 fetchedTor.setCodecName(codecForTr);
       
   504                 cd.m_outputCodec = codecForTr;
   497             }
   505             }
   498             tmp = variables.value("CODECFORSRC");
   506             tmp = variables.value("CODECFORSRC");
   499             if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
   507             if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
   500                 codecForSource = tmp.first().toLatin1();
   508                 codecForSource = tmp.first().toLatin1();
   501                 if (!QTextCodec::codecForName(codecForSource))
   509                 if (!QTextCodec::codecForName(codecForSource))