40information from qmake projects and passes it to lupdate.
41All command line options that are not consumed by lupdate-pro are
42passed to lupdate.
43
44Options:
45 -help Display this information and exit.
46 -silent
47 Do not explain what is being done.
48 -pro <filename>
49 Name of a .pro file. Useful for files with .pro file syntax but
50 different file suffix. Projects are recursed into and merged.
51 -dump-json <file>
52 Only generate the project description json file.
53 -pro-out <directory>
54 Virtual output directory for processing subsequent .pro files.
55 -pro-debug
56 Trace processing .pro files. Specify twice for more verbosity.
57 -version
58 Display the version of lupdate-pro and exit.
59)"_s);
62int main(
int argc,
char **argv)
64 QCoreApplication app(argc, argv);
65#ifndef QT_BOOTSTRAPPED
67 QTranslator translator;
68 QTranslator qtTranslator;
69 QString sysLocale = QLocale::system().name();
70 QString resourceDir = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
71 if (translator.load(
"linguist_"_L1 + sysLocale, resourceDir)
72 && qtTranslator.load(
"qt_"_L1 + sysLocale, resourceDir)) {
73 app.installTranslator(&translator);
74 app.installTranslator(&qtTranslator);
79 QStringList args = app.arguments();
80 std::optional<QString> dumpJsonFile;
83 QString outDir = QDir::currentPath();
84 QHash<QString, QString> outDirMap;
88 QStringList tsFileNames;
89 QStringList alienFiles;
90 QString sourceLanguage;
91 QString targetLanguage;
92 UpdateOptions options =
Verbose |
95 for (
int i = 1; i < args.size(); ++i) {
96 QString arg = args.at(i);
97 if (arg ==
"-help"_L1 || arg ==
"--help"_L1 || arg ==
"-h"_L1) {
100 }
else if (arg ==
"-dump-json"_L1) {
103 printErr(u"The -dump-json option should be followed by a file name.\n"_s);
106 dumpJsonFile.emplace(QFileInfo(args[i]).absoluteFilePath());
107 }
else if (arg ==
"-silent"_L1) {
110 }
else if (arg ==
"-verbose"_L1) {
112 }
else if (arg ==
"-pro-debug"_L1) {
114 }
else if (arg ==
"-version"_L1) {
115 printOut(QStringLiteral(
"lupdate-pro version %1\n").arg(QLatin1String(QT_VERSION_STR)));
117 }
else if (arg ==
"-pro"_L1) {
120 printErr(u"The -pro option should be followed by a filename of .pro file.\n"_s);
123 QString file = QDir::cleanPath(QFileInfo(args[i]).absoluteFilePath());
125 outDirMap[file] = outDir;
126 }
else if (arg ==
"-pro-out"_L1) {
129 printErr(u"The -pro-out option should be followed by a directory name.\n"_s);
132 outDir = QDir::cleanPath(QFileInfo(args[i]).absoluteFilePath());
133 }
else if (arg ==
"-ts"_L1) {
135 while (i < args.size() && !args.at(i).startsWith(
'-'_L1)) {
136 tsFileNames << args.at(i);
140 }
else if (arg ==
"-target-language"_L1) {
143 targetLanguage = args.at(i);
144 }
else if (arg ==
"-source-language"_L1) {
147 sourceLanguage = args.at(i);
148 }
else if (arg ==
"-no-obsolete"_L1 || arg ==
"-noobsolete"_L1) {
150 }
else if (arg ==
"-plural-only"_L1) {
152 }
else if (arg ==
"-no-sort"_L1 || arg ==
"-nosort"_L1) {
154 }
else if (arg ==
"-locations"_L1) {
156 if (i < args.size()) {
157 if (args.at(i) ==
"none"_L1)
159 else if (args.at(i) ==
"relative"_L1)
161 else if (args.at(i) ==
"absolute"_L1)
164 }
else if (arg ==
"-no-ui-lines"_L1) {
166 }
else if (arg ==
"-tr-function-alias"_L1) {
169 printErr(u"The -tr-function-alias option should be "
170 "followed by a list of function=alias mappings.\n"_s);
173 if (!parseTrFunctionAliasString(args[i]))
175 }
else if (isProOrPriFile(arg)) {
176 QString cleanFile = QDir::cleanPath(QFileInfo(arg).absoluteFilePath());
177 proFiles << cleanFile;
178 outDirMap[cleanFile] = outDir;
182 if (proFiles.isEmpty()) {
183 printErr(u"lupdate-pro: No .pro/.pri files given.\n"_s);
187 QStringList translationsVariables = {
"TRANSLATIONS"_L1 };
190 Projects projectDescription = generateProjects(proFiles, translationsVariables, outDirMap,
191 proDebug, verbose, &errorString, &results);
194 QFile projectDescriptionFile(*dumpJsonFile);
195 if (!projectDescriptionFile.open(QIODevice::WriteOnly))