44 #include <QtCore/QCoreApplication> |
44 #include <QtCore/QCoreApplication> |
45 #include <QtCore/QDebug> |
45 #include <QtCore/QDebug> |
46 #include <QtCore/QString> |
46 #include <QtCore/QString> |
47 #include <QtCore/QStringList> |
47 #include <QtCore/QStringList> |
48 |
48 |
|
49 #include <iostream> |
|
50 |
49 static int usage(const QStringList &args) |
51 static int usage(const QStringList &args) |
50 { |
52 { |
51 Q_UNUSED(args); |
53 Q_UNUSED(args); |
52 |
54 |
53 QString loaders; |
55 QString loaders; |
54 QString line(QLatin1String(" %1 - %2\n")); |
56 QString line(QLatin1String(" %1 - %2\n")); |
55 foreach (Translator::FileFormat format, Translator::registeredFileFormats()) |
57 foreach (Translator::FileFormat format, Translator::registeredFileFormats()) |
56 loaders += line.arg(format.extension, -5).arg(format.description); |
58 loaders += line.arg(format.extension, -5).arg(format.description); |
57 |
59 |
58 qWarning("%s", qPrintable(QString(QLatin1String("\nUsage:\n" |
60 std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n" |
59 " lconvert [options] <infile> [<infile>...]\n\n" |
61 " lconvert [options] <infile> [<infile>...]\n\n" |
60 "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" |
62 "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" |
61 "stand-alone tool to convert and filter translation data files.\n" |
63 "stand-alone tool to convert and filter translation data files.\n" |
62 "The following file formats are supported:\n\n%1\n" |
64 "The following file formats are supported:\n\n%1\n" |
63 "If multiple input files are specified, they are merged with\n" |
65 "If multiple input files are specified, they are merged with\n" |
237 |
239 |
238 if (!tr.load(inFiles[0].name, cd, inFiles[0].format)) { |
240 if (!tr.load(inFiles[0].name, cd, inFiles[0].format)) { |
239 qWarning() << qPrintable(cd.error()); |
241 qWarning() << qPrintable(cd.error()); |
240 return 2; |
242 return 2; |
241 } |
243 } |
242 Translator::reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose); |
244 tr.reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose); |
243 |
245 |
244 for (int i = 1; i < inFiles.size(); ++i) { |
246 for (int i = 1; i < inFiles.size(); ++i) { |
245 Translator tr2; |
247 Translator tr2; |
246 if (!tr2.load(inFiles[i].name, cd, inFiles[i].format)) { |
248 if (!tr2.load(inFiles[i].name, cd, inFiles[i].format)) { |
247 qWarning() << qPrintable(cd.error()); |
249 qWarning() << qPrintable(cd.error()); |
248 return 2; |
250 return 2; |
249 } |
251 } |
250 Translator::reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose); |
252 tr2.reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose); |
251 for (int j = 0; j < tr2.messageCount(); ++j) |
253 for (int j = 0; j < tr2.messageCount(); ++j) |
252 tr.replaceSorted(tr2.message(j)); |
254 tr.replaceSorted(tr2.message(j)); |
253 } |
255 } |
254 |
256 |
255 if (!targetLanguage.isEmpty()) |
257 if (!targetLanguage.isEmpty()) |