qt_create_translation | Qt Linguist Manual

- Qt 6.4
- Qt Linguist Manual
- qt_create_translation
- Qt 6.4.1 Reference Documentation

# qt_create_translation

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)