Collects targets that are eligible for translation.

The command is defined in the LinguistTools component of the Qt6 package. Load the package with:

find_package(Qt6 REQUIRED COMPONENTS LinguistTools)

This command was introduced in Qt 6.7.


qt_collect_i18n_targets(out_var [DIRECTORY path])

If versionless commands are disabled, use qt6_collect_i18n_targets() instead. It supports the same set of arguments as this command.


Collect targets that are eligible for translation in the given DIRECTORY and all subdirectories. If DIRECTORY is not specified, start the target collection at CMAKE_CURRENT_SOURCE_DIR.

The command stores the list of targets in the variable that is specified as first argument.

Excluding targets from translation

By default, all non-imported executable and library targets are eligible for translation.

Single targets can be excluded by setting the target property QT_EXCLUDE_FROM_TRANSLATION.

Targets below a certain directory can be excluded by setting the directory property QT_EXCLUDE_FROM_TRANSLATION.

When to call this command

The qt_collect_i18n_targets command reads the BUILDSYSTEM_TARGETS directory properties. As a consequence, it only collects targets that already have been created. Targets that are created after qt_collect_i18n_targets has been called are not collected.

To collect all targets of the build system, call qt_collect_i18n_targets at the end of the top-level CMakeLists.txt or use cmake_language(DEFER CALL) to set up i18n at the end of the top-level directory scope.


Use the result of qt_collect_i18n_targets as input for qt_add_lupdate.

add_subdirectory(src)          # the actual application is defined here

qt_add_lupdate(TARGETS ${i18n_targets})

add_subdirectory(tests)        # unit tests - we don't want to translate those

© 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.