qt_create_translation

Sets up the Qt Linguist translation toolchain.

命令的定义在 LinguistTools 组件对于 Qt6 package. Load the package with:

find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
					

警告: This function is deprecated. Consider using the target-based functions qt6_add_lupdate or qt6_add_translations 代替。

概要

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

无版本命令 被禁用,使用 qt6_create_translation 代替。它支持如此命令的一组相同自变量。

描述

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.

选项

可以设置额外 选项 that should be passed when lupdate is invoked. You can find possible options in the lupdate documentation .

范例

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)