Using lrelease

The lrelease command line tool produces QM files out of TS files. The QM file format is a compact binary format that the localized application uses. It provides extremely fast lookup for translations.

When building with qmake, specify the files to process at the command line or in a .pro file.

When building with CMake, use CMake commands to add targets that create or update TS files and transform them into QM files. The lrelease tool is run with the options you pass to the commands when you build the target.

Run lrelease whenever you want to release the application, from the initial test version through to the final release version. The application does not need QM files to run, but if they are available, the application detects them and uses them automatically.

Note: The lrelease tool only incorporates translations that you mark as finished. Otherwise, it uses the original text instead.

lrelease syntax

lrelease [options] -project project-file
lrelease [options] ts-files [-qm qm-file]

Where:

  • options means one or several lrelease options.
  • project-file is the project configuration file.
  • ts-files are the TS files to use as input for the QM files.
  • qm-file is the name of the QM file to generate.

Note: Passing .pro files to lrelease is deprecated. Use the lrelease-pro tool or the lrelease.prf feature when using qmake.

To view the latest help, enter:

lrelease -help

lrelease options

OptionAction
-helpDisplay up-to-date help information and exit.
-idbasedUse IDs instead of source strings for message keying.
-compressCompress the QM files.
-nounfinishedDo not include unfinished translations.
-removeidenticalIf the translated text is the same as the source text, exclude the message.
-markuntranslated <prefix>If a message has no real translation, use the source text prefixed with the given string instead.
-project <filename>Name of a file containing the project's description in JSON format. You can use the lprodump tool to generate the file from a .pro file.
-silentDo not explain what is being done.
-versionDisplay the version of lrelease and exit.

Examples

Using lrelease with CMake

When building with CMake, use CMake commands to add translations on targets to the CMakeLists.txt file, and then build the targets.

Select one of the following options:

Build a target (for example, app_lrelease) to update the .qm files for it. To update the .qm files for all targets, build the target release_translations.

Using lrelease with qmake

To run lrelease without specifying a project file:

lrelease.exe main_en.ts languages\main_fr.ts

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.