42 lrelease [options] -project project-file
43 lrelease [options] ts-files [-qm qm-file]
44
45lrelease is part of Qt's Linguist tool chain. It can be used as a
46stand-alone tool to convert XML-based translations files in the TS
47format into the 'compiled' QM format used by QTranslator objects.
48
49Passing .pro files to lrelease is deprecated.
50Please use the lrelease-pro tool instead, or use qmake's lrelease.prf
51feature.
52
53Options:
54 -help Display this information and exit
55 -idbased
56 Use IDs instead of source strings for message keying
57 -compress
58 Compress the QM files
59 -nounfinished
60 Do not include unfinished translations
61 -removeidentical
62 If the translated text is the same as
63 the source text, do not include the message
64 -markuntranslated <prefix>
65 If a message has no real translation, use the source text
66 prefixed with the given string instead
67 -project <filename>
68 Name of a file containing the project's description in JSON format.
69 Such a file may be generated from a .pro file using the lprodump tool.
70 -silent
71 Do not explain what is being done
72 -version
73 Display the version of lrelease and exit
74)"_s);
129 if (!loadTsFile(tor, tsFileName, cd.isVerbose()))
132 QString qmFileName = tsFileName;
133 for (
const Translator::FileFormat &fmt : std::as_const(Translator::registeredFileFormats())) {
134 if (qmFileName.endsWith(QLatin1Char(
'.') + fmt.extension)) {
135 qmFileName.chop(fmt.extension.size() + 1);
139 qmFileName += QLatin1String(
".qm");
141 return releaseTranslator(tor, qmFileName, cd, removeIdentical);
170 QCoreApplication app(argc, argv);
174 bool removeIdentical =
false;
176 QStringList inputFiles;
178 QString projectDescriptionFile;
180 for (
int i = 1; i < argc; ++i) {
181 if (!strcmp(argv[i],
"-compress")) {
184 }
else if (!strcmp(argv[i],
"-idbased")) {
187 }
else if (!strcmp(argv[i],
"-nocompress")) {
190 }
else if (!strcmp(argv[i],
"-removeidentical")) {
191 removeIdentical =
true;
193 }
else if (!strcmp(argv[i],
"-nounfinished")) {
196 }
else if (!strcmp(argv[i],
"-markuntranslated")) {
201 cd.m_unTrPrefix = QString::fromLocal8Bit(argv[++i]);
202 }
else if (!strcmp(argv[i],
"-project")) {
204 printErr(QLatin1String(
"The option -project requires a parameter.\n"));
207 if (!projectDescriptionFile.isEmpty()) {
208 printErr(QLatin1String(
"The option -project must appear only once.\n"));
211 projectDescriptionFile = QString::fromLocal8Bit(argv[++i]);
212 }
else if (!strcmp(argv[i],
"-silent")) {
215 }
else if (!strcmp(argv[i],
"-verbose")) {
218 }
else if (!strcmp(argv[i],
"-version")) {
219 printOut(QLatin1String(
"lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)));
221 }
else if (!strcmp(argv[i],
"-qm")) {
226 outputFile = QString::fromLocal8Bit(argv[++i]);
227 }
else if (!strcmp(argv[i],
"-help")) {
230 }
else if (argv[i][0] ==
'-') {
234 inputFiles << QString::fromLocal8Bit(argv[i]);
238 if (inputFiles.isEmpty() && projectDescriptionFile.isEmpty()) {
244 if (!extractProFiles(&inputFiles).isEmpty()) {
245 runInternalQtTool(QLatin1String(
"lrelease-pro"), app.arguments().mid(1));
249 if (!projectDescriptionFile.isEmpty()) {
250 if (!inputFiles.isEmpty()) {
251 printErr(QLatin1String(
252 "lrelease error: Do not specify TS files if -project is given.\n"));
255 Projects projectDescription = readProjectDescription(projectDescriptionFile, &errorString);
256 if (!errorString.isEmpty()) {
257 printErr(QLatin1String(
"lrelease error: %1\n").arg(errorString));
260 inputFiles = translationsFromProjects(projectDescription);
263 for (
const QString &inputFile : std::as_const(inputFiles)) {
264 if (outputFile.isEmpty()) {
265 if (!releaseTsFile(inputFile, cd, removeIdentical))
268 if (!loadTsFile(tor, inputFile, cd.isVerbose()))
273 if (!outputFile.isEmpty())
274 return releaseTranslator(tor, outputFile, cd, removeIdentical) ? 0 : 1;
QTextStream stream(stdin)
[0]