- Qt 6.5
- Qt Linguist Manual
- Using lrelease
- Qt 6.5.0 Reference Documentation

Using lupdate ◦ Translators

# 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

Option | Action
--- | ---
`-help` | Display up-to-date help information and exit.
`-idbased` | Use IDs instead of source strings for message keying.
`-compress` | Compress the QM files.
`-nounfinished` | Do not include unfinished translations.
`-removeidentical` | If 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.
`-silent` | Do not explain what is being done.
`-version` | Display 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:

- Use qt_add_translations on a target, such as app. This calls qt_add_lupdate and qt_add_lrelease.
- Use `qt_add_lrelease` on a target.

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

Using lupdate ◦ Translators