43 |
43 |
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 #include <QtCore/QTranslator> |
|
49 #include <QtCore/QLibraryInfo> |
48 |
50 |
49 #include <iostream> |
51 #include <iostream> |
50 |
52 |
51 QT_USE_NAMESPACE |
53 QT_USE_NAMESPACE |
|
54 |
|
55 class LC { |
|
56 Q_DECLARE_TR_FUNCTIONS(LConvert) |
|
57 }; |
52 |
58 |
53 static int usage(const QStringList &args) |
59 static int usage(const QStringList &args) |
54 { |
60 { |
55 Q_UNUSED(args); |
61 Q_UNUSED(args); |
56 |
62 |
57 QString loaders; |
63 QString loaders; |
58 QString line(QLatin1String(" %1 - %2\n")); |
64 QString line(QLatin1String(" %1 - %2\n")); |
59 foreach (Translator::FileFormat format, Translator::registeredFileFormats()) |
65 foreach (Translator::FileFormat format, Translator::registeredFileFormats()) |
60 loaders += line.arg(format.extension, -5).arg(format.description); |
66 loaders += line.arg(format.extension, -5).arg(format.description); |
61 |
67 |
62 std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n" |
68 std::cerr << qPrintable(LC::tr("\nUsage:\n" |
63 " lconvert [options] <infile> [<infile>...]\n\n" |
69 " lconvert [options] <infile> [<infile>...]\n\n" |
64 "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" |
70 "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" |
65 "stand-alone tool to convert and filter translation data files.\n" |
71 "stand-alone tool to convert and filter translation data files.\n" |
66 "The following file formats are supported:\n\n%1\n" |
72 "The following file formats are supported:\n\n%1\n" |
67 "If multiple input files are specified, they are merged with\n" |
73 "If multiple input files are specified, they are merged with\n" |
132 }; |
138 }; |
133 |
139 |
134 int main(int argc, char *argv[]) |
140 int main(int argc, char *argv[]) |
135 { |
141 { |
136 QCoreApplication app(argc, argv); |
142 QCoreApplication app(argc, argv); |
|
143 QTranslator translator; |
|
144 QTranslator qtTranslator; |
|
145 QString sysLocale = QLocale::system().name(); |
|
146 QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
|
147 if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir) |
|
148 && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) { |
|
149 app.installTranslator(&translator); |
|
150 app.installTranslator(&qtTranslator); |
|
151 } |
|
152 |
137 QStringList args = app.arguments(); |
153 QStringList args = app.arguments(); |
138 |
|
139 QList<File> inFiles; |
154 QList<File> inFiles; |
140 QString inFormat(QLatin1String("auto")); |
155 QString inFormat(QLatin1String("auto")); |
141 QString outFileName; |
156 QString outFileName; |
142 QString outFormat(QLatin1String("auto")); |
157 QString outFormat(QLatin1String("auto")); |
143 QString targetLanguage; |
158 QString targetLanguage; |