qt_add_translation

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

概要

qt_add_translation(<VAR> file1.ts [file2.ts ...]
                    [OPTIONS ...])
					

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

描述

调用 lrelease on each .ts file passed as an argument, generating .qm files. The paths of the generated files are added to <VAR> .

选项

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

默认情况下, qm files will be placed in the current build directory ( CMAKE_CURRENT_BINARY_DIR ). To change this, you can set OUTPUT_LOCATION as a property of the source .ts 文件。

For example, with the following code, the .qm files are generated in a translations directory below the current build directory.

set_source_files_properties(app_en.ts app_de.ts
    PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
					

范例

Generating helloworld_en.qm , helloworld_de.qm in the build directory:

qt_add_translation(qmFiles helloworld_en.ts helloworld_de.ts)
					

Generating helloworld_en.qm , helloworld_de.qm l10n sub-directory:

set(TS_FILES helloworld_en.ts helloworld_de.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "l10n")
qt_add_translation(qmFiles ${TS_FILES})