qt_deploy_translations

部署可执行文件所需的 Qt 翻译。

该命令在Qt6 软件包的Core 组件中定义,可以像这样加载:

find_package(Qt6 REQUIRED COMPONENTS Core)

与 Qt 提供的大多数其他 CMake 命令不同,qt_deploy_translations() 只能从部署脚本中调用。项目不能在配置阶段直接调用它。

该命令在 Qt 6.5 中引入。

注意: 该命令处于技术预览阶段,在未来版本中可能会有所改变。

注意: 通常不需要直接调用此命令。它在内部被其他更高级的命令使用,但希望实现更多自定义部署逻辑的项目可能会发现它很有用。

简介

qt_deploy_translations(
    [CATALOGS catalogs]
    [LOCALES locales]
    [LCONVERT lconvert_executable]
    [VERBOSE]
)

说明

安装应用程序时,最好也安装属于所用 Qt 模块的翻译。qt_deploy_translations 命令从 Qt 安装中收集必要的.qm 文件,并将它们编译成每种语言的一个qt_${language}.qm 文件。.qm 文件将安装到QT_DEPLOY_TRANSLATIONS_DIR 中。

参数

LOCALES 参数指定应部署哪些本地化翻译。这是Qt Linguist 的翻译手册中描述的语言/地区组合列表。有效的本地化示例有de,plpt_BR

如果省略LOCALES ,则部署所有可用的本地语言。

CATALOGS 参数指定了要部署的翻译目录列表。如果省略该参数,则会部署属于项目中通过find_package 使用的任何 Qt 模块的所有目录。

LCONVERT 参数指定用于合并目录的lconvert 可执行文件。默认情况下,使用 Qt 安装的lconvert

为便于调试,可以设置VERBOSE 参数来打开诊断信息。

示例

下面的示例部署了 Qt 库的丹麦语和德语翻译。

qt_deploy_translations(
    LOCALES da de
)

另请参阅 QT_DEPLOY_TRANSLATIONS_DIR

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