qt_create_translation

Sets up the Qt Linguist translation toolchain.

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

find_package(Qt6 REQUIRED COMPONENTS LinguistTools)

Warning: This function is deprecated. Consider using the target-based functions qt6_add_lupdate or qt6_add_translations instead.

Synopsis

qt_create_translation(<VAR> ts-file-or-sources [ts-file-or-sources2 ...]
                      [OPTIONS ...])

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

Description

Processes given sources (directories or individual files) to generate Qt Linguist .ts files. The .ts files are in turn compiled into .qm files of the same base name that are stored in the build directory. Paths to the generated .qm files are added to <VAR>.

The translation files to create or update need to have a .ts suffix. If the given file path is not absolute it is resolved relative to the current source directory. If no .ts file is passed as an argument, the macro does nothing.

Any arguments that do not have a .ts suffix are passed as input to the lupdate. lupdate accepts directories and source files as input. See also the lupdate documentation on further details.

Options

You can set additional OPTIONS that should be passed when lupdate is invoked. You can find possible options in the lupdate documentation.

Examples

Recursively look up Qt translations from source files in current directory and generate or update helloworld_en.ts and helloworld_de.ts file using lupdate. Compile said files into helloworld_en.qm and helloworld.de.qm files in the build directory:

qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} helloworld_en.ts helloworld_de.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.