Add targets to generate or update Qt Linguist .ts files.
命令的定义在
LinguistTools
组件对于
Qt6
包。加载包采用:
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
该命令在 Qt 6.2 引入。
Since 6.7:
qt_add_lupdate(TS_FILES file1.ts [file2.ts ...] [PLURALS_TS_FILE file.ts] [SOURCE_TARGETS target1 [target2 ...]] [SOURCES source1.cpp [sources2.cpp ...]] [INCLUDE_DIRECTORIES directory1 [directory2 ...]] [LUPDATE_TARGET target-name] [NO_GLOBAL_TARGET] [OPTIONS ...])
Since 6.2 (deprecated):
qt_add_lupdate(target TS_FILES file1.ts [file2.ts ...] [SOURCES source1.cpp [sources2.cpp ...]] [INCLUDE_DIRECTORIES directory1 [directory2 ...]] [NO_GLOBAL_TARGET] [OPTIONS ...])
若
无版本命令
被禁用,使用
qt6_add_lupdate()
代替。它支持如此命令的一组相同自变量。
Creates a custom target to generate or update Qt Linguist
.ts
files with
lupdate
.
The name of that custom target defaults to
${PROJECT_NAME}_lupdate
. Further calls of
qt_add_lupdate
will create target names with an increasing number appended. The custom target name can be specified with the
LUPDATE_TARGET
选项。
With the
SOURCE_TARGETS
argument you can specify a list of targets that contain sources with translatable strings. If
SOURCE_TARGETS
is not specified, you can specify
SOURCES
, which is described below. If neither
SOURCE_TARGETS
nor
SOURCES
is given, the command
qt_collect_translation_source_targets
is called to retrieve the list of targets.
The
.ts
files must be specified with the argument
TS_FILES
.
This function is designed to be used in conjunction with qt_add_lrelease . See also the convenience wrapper qt_add_translations .
采用
SOURCES
you can explicitly specify additional source files that contain translatable strings.
可以使用
INCLUDE_DIRECTORIES
to explicitly specify include directories for those source files.
可以设置额外
选项
that should be passed when
lupdate
is invoked. You can find possible options in the
lupdate documentation
.
In addition to the target
${target}_lupdate
, an umbrella target
update_translations
is created. This target will build all
${target}_lupdate
targets that were created with
qt_add_lupdate
.
Pass
NO_GLOBAL_TARGET
to
qt_add_lupdate
to prevent this behavior.
The name of this target can be overridden by setting the variable
QT_GLOBAL_LUPDATE_TARGET
before calling
qt_add_lupdate
.
QT_I18N_SOURCE_LANGUAGE
specifies the language in which the source code strings are written. For handling plural forms correctly, create an additional
.ts
file for that language that only contains translatable strings for plural forms. See
句柄复数形式
了解细节。
采用
PLURALS_TS_FILE
you can specify the
.ts
file for the source language. This file will only contain plural forms.
Older versions of
qt_add_lupdate
took a target as the first argument. This is deprecated. Use the
SOURCE_TARGETS
argument instead.
Add the targets
myapp_lupdate
and
update_translations
for updating the
.ts
file of an application
myapp
.
qt_add_lupdate( SOURCE_TARGETS myapp TS_FILES myapp_de.ts PLURALS_TS_FILE myapp_en.ts )
You can specify the name of the created target by passing the
LUPDATE_TARGET
自变量:
qt_add_lupdate( LUPDATE_TARGET update_application_translations TS_FILES myapp_de.ts PLURALS_TS_FILE myapp_en.ts )