Changeset 846 for trunk/tools/linguist/lrelease/main.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/linguist/lrelease/main.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 56 56 #include <QtCore/QTextStream> 57 57 58 #include <iostream> 59 58 60 QT_USE_NAMESPACE 59 61 … … 64 66 #endif 65 67 ); 68 69 struct LR { 70 static inline QString tr(const char *sourceText, const char *comment = 0) 71 { 72 return QCoreApplication::translate("LRelease", sourceText, comment); 73 } 74 }; 75 #else 76 class LR { 77 Q_DECLARE_TR_FUNCTIONS(LRelease) 78 }; 66 79 #endif 67 80 … … 74 87 static void printUsage() 75 88 { 76 printOut( QCoreApplication::tr(89 printOut(LR::tr( 77 90 "Usage:\n" 78 91 " lrelease [options] project-file\n" … … 107 120 bool ok = tor.load(tsFileName, cd, QLatin1String("auto")); 108 121 if (!ok) { 109 qWarning("lrelease error: %s\n", qPrintable(cd.error()));122 std::cerr << qPrintable(LR::tr("lrelease error: %1").arg(cd.error())); 110 123 } else { 111 124 if (!cd.errors().isEmpty()) … … 122 135 123 136 if (cd.isVerbose()) 124 printOut( QCoreApplication::tr("Updating '%1'...\n").arg(qmFileName));137 printOut(LR::tr("Updating '%1'...\n").arg(qmFileName)); 125 138 if (removeIdentical) { 126 139 if (cd.isVerbose()) 127 printOut( QCoreApplication::tr("Removing translations equal to source text in '%1'...\n").arg(qmFileName));140 printOut(LR::tr("Removing translations equal to source text in '%1'...\n").arg(qmFileName)); 128 141 tor.stripIdenticalSourceTranslations(); 129 142 } … … 131 144 QFile file(qmFileName); 132 145 if (!file.open(QIODevice::WriteOnly)) { 133 qWarning("lrelease error: cannot create '%s': %s\n",134 qPrintable(qmFileName), qPrintable(file.errorString()));146 std::cerr << qPrintable(LR::tr("lrelease error: cannot create '%1': %2\n") 147 .arg(qmFileName, file.errorString())); 135 148 return false; 136 149 } … … 141 154 142 155 if (!ok) { 143 qWarning("lrelease error: cannot save '%s': %s\n",144 qPrintable(qmFileName), qPrintable(cd.error()));156 std::cerr << qPrintable(LR::tr("lrelease error: cannot save '%1': %2") 157 .arg(qmFileName, cd.error())); 145 158 } else if (!cd.errors().isEmpty()) { 146 159 printOut(cd.error()); … … 179 192 #else 180 193 QCoreApplication app(argc, argv); 194 #ifndef Q_OS_WIN32 181 195 QTranslator translator; 182 if (translator.load(QLatin1String("lrelease_") + QLocale::system().name())) 196 QTranslator qtTranslator; 197 QString sysLocale = QLocale::system().name(); 198 QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); 199 if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir) 200 && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) { 183 201 app.installTranslator(&translator); 184 #endif 202 app.installTranslator(&qtTranslator); 203 } 204 #endif // Q_OS_WIN32 205 #endif // QT_BOOTSTRAPPED 185 206 186 207 ConversionData cd; … … 220 241 continue; 221 242 } else if (!strcmp(argv[i], "-version")) { 222 printOut( QCoreApplication::tr( "lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)));243 printOut(LR::tr("lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR))); 223 244 return 0; 224 245 } else if (!strcmp(argv[i], "-qm")) { … … 254 275 255 276 if (!visitor.queryProFile(&pro)) { 256 qWarning("lrelease error: cannot read project file '%s'.", qPrintable(inputFile)); 277 std::cerr << qPrintable(LR::tr( 278 "lrelease error: cannot read project file '%1'.\n") 279 .arg(inputFile)); 257 280 continue; 258 281 } 259 282 if (!visitor.accept(&pro)) { 260 qWarning("lrelease error: cannot process project file '%s'.", qPrintable(inputFile)); 283 std::cerr << qPrintable(LR::tr( 284 "lrelease error: cannot process project file '%1'.\n") 285 .arg(inputFile)); 261 286 continue; 262 287 } … … 264 289 QStringList translations = visitor.values(QLatin1String("TRANSLATIONS")); 265 290 if (translations.isEmpty()) { 266 qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in"267 " project file '%s'\n",268 qPrintable(inputFile));291 std::cerr << qPrintable(LR::tr( 292 "lrelease warning: Met no 'TRANSLATIONS' entry in project file '%1'\n") 293 .arg(inputFile)); 269 294 } else { 270 295 QDir proDir(fi.absolutePath());
Note:
See TracChangeset
for help on using the changeset viewer.