qt_deploy_translations

Deploy Qt translations needed by an executable.

The command is defined in the Core component of the Qt6 package, which can be loaded like so:

 find_package(Qt6 REQUIRED COMPONENTS Core)

Unlike most other CMake commands provided by Qt, qt_deploy_translations() can only be called from a deployment script. It cannot be called directly by the project during the configure stage.

This command was introduced in Qt 6.5.

Note: This command is in technology preview and may change in future releases.

Note: This command does not usually need to be called directly. It is used internally by other higher level commands, but projects wishing to implement more customized deployment logic may find it useful.

Synopsis

 qt_deploy_translations(
     [CATALOGS catalogs]
     [LOCALES locales]
     [LCONVERT lconvert_executable]
     [VERBOSE]
 )

Description

When installing an application, it may be desirable to also install the translations that belong to the used Qt modules. The qt_deploy_translations command collects the necessary .qm file from the Qt installation and compiles them into one qt_${language}.qm file per language. The .qm files are installed into QT_DEPLOY_TRANSLATIONS_DIR.

Arguments

The LOCALES argument specifies for which locales translations should be deployed. This is a list of language/region combinations as described in Qt Linguist's manual for translators. Examples for valid locales are: de, pl, or pt_BR.

If LOCALES is omitted, then all available locales are deployed.

The CATALOGS argument specifies a list of translation catalogs to be deployed. If this argument is omitted, then all catalogs are deployed that belong to any Qt module that is used in the project via find_package.

The LCONVERT argument specifies the lconvert executable that is used to combine the catalogs. By default, the Qt installation's lconvert is used.

For debugging purposes, the VERBOSE argument can be set to turn on diagnostic messages.

Example

The following example deploys Danish and German translations of the Qt libraries.

 qt_deploy_translations(
     LOCALES da de
 )

See also QT_DEPLOY_TRANSLATIONS_DIR.