29lrelease-pro is part of Qt's Linguist tool chain. It extracts project
30information from qmake projects and passes it to lrelease.
31All command line options that are not consumed by lrelease-pro are
32passed to lrelease.
33
34Options:
35 -help Display this information and exit
36 -dump-json <file>
37 Only generate the project description json file.
38 -fail-on-invalid
39 Fail if translations failing the following checks are found:
40 validity check of accelerators
41 validity check of surrounding whitespaces
42 validity check of ending punctuation
43 validity check of place markers
44 To get more details refer to Qt Linguist help
45 -silent
46 Do not explain what is being done
47 -version
48 Display the version of lrelease-pro and exit
49)"_s);
52int main(
int argc,
char **argv)
54 QCoreApplication app(argc, argv);
55#ifndef QT_BOOTSTRAPPED
57 QTranslator translator;
58 QTranslator qtTranslator;
59 QString sysLocale = QLocale::system().name();
60 QString resourceDir = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
61 if (translator.load(
"linguist_"_L1 + sysLocale, resourceDir)
62 && qtTranslator.load(
"qt_"_L1 + sysLocale, resourceDir)) {
63 app.installTranslator(&translator);
64 app.installTranslator(&qtTranslator);
69 std::optional<QString> dumpJsonFile;
70 QStringList inputFiles;
73 QString markUntranslated;
76 for (
int i = 1; i < argc; ++i) {
77 QString arg = QString::fromLocal8Bit(argv[i]);
78 if (arg ==
"-silent"_L1) {
80 }
else if (arg ==
"-verbose"_L1) {
82 }
else if (arg ==
"-version"_L1) {
83 printOut(QStringLiteral(
"lrelease-pro version %1\n")
84 .arg(QLatin1String(QT_VERSION_STR)));
86 }
else if (arg ==
"-help"_L1) {
89 }
else if (arg ==
"-dump-json"_L1) {
92 printErr(u"The -dump-json option should be followed by a file name.\n"_s);
95 dumpJsonFile.emplace(QFileInfo(QLatin1String(argv[i])).absoluteFilePath());
96 }
else if (arg ==
"-removeidentical"_L1) {
98 }
else if (arg ==
"-fail-on-unfinished"_L1) {
100 }
else if (arg ==
"-fail-on-invalid"_L1) {
102 }
else if (arg ==
"-nounfinished"_L1) {
104 }
else if (arg ==
"-markuntranslated"_L1) {
107 markUntranslated = QString::fromLocal8Bit(argv[i]);
108 }
else if (arg ==
"-idbased"_L1) {
109 printOut(
"The flag -idbased is deprecated and not required anymore."
110 "It will be removed in a future version\n"_L1);
111 }
else if (!arg.startsWith(u'-')) {
116 if (inputFiles.isEmpty()) {
121 const QStringList proFiles = extractProFiles(&inputFiles);
122 if (proFiles.isEmpty()) {
123 printErr(u"lrelease-pro: No .pro/.pri files given.\n"_s);
126 if (!inputFiles.isEmpty()) {
127 printErr(QStringLiteral(
"lrelease-pro: Only .pro/.pri files are supported. "
128 "Offending files:\n %1\n")
129 .arg(inputFiles.join(
"\n "_L1)));
133 QStringList translationsVariables = {
"TRANSLATIONS"_L1,
"EXTRA_TRANSLATIONS"_L1 };
134 QString outDir = QDir::currentPath();
135 QHash<QString, QString> outDirMap;
137 QStringList cleanProFiles;
138 for (
const QString &proFile : proFiles) {
139 QString cleanFile = QDir::cleanPath(QFileInfo(proFile).absoluteFilePath());
140 cleanProFiles << cleanFile;
141 outDirMap[cleanFile] = outDir;
146 Projects projects = generateProjects(cleanProFiles, translationsVariables, outDirMap, 0,
147 cd.m_verbose, &errorString, &results);
150 QFile projectDescriptionFile(*dumpJsonFile);
151 if (!projectDescriptionFile.open(QIODevice::WriteOnly))
154 const QByteArray output = QJsonDocument(results).toJson(QJsonDocument::Compact);
155 projectDescriptionFile.write(output);
156 projectDescriptionFile.write(
"\n");
157 projectDescriptionFile.close();
158 printOut(
"Project description saved to: %1\n"_L1.arg(projectDescriptionFile.fileName()));
162 if (!errorString.isEmpty()) {
163 printErr(QStringLiteral(
"lrelease-pro error: %1\n").arg(errorString));