- Qt 6.11
- Qt Linguist Manual
- CMake Commands in Qt6 LinguistTools
- qt_add_lupdate
- Qt 6.11.2 Reference Documentation

# qt_add_lupdate

Add targets to generate or update Qt Linguist .ts files.

The command is defined in the `LinguistTools` component of the `Qt6` package. Load the package with:

     find_package(Qt6 REQUIRED COMPONENTS LinguistTools)

This command was introduced in Qt 6.2.

## Synopsis

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 ...])

If versionless commands are disabled, use `qt6_add_lupdate()` instead. It supports the same set of arguments as this command.

## Description

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` option.

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 and Include Directories

With `SOURCES` you can explicitly specify additional source files that contain translatable strings.

You can use `INCLUDE_DIRECTORIES` to explicitly specify include directories for those source files.

## Options

You can set additional `OPTIONS` that should be passed when `lupdate` is invoked. You can find possible options in the lupdate documentation.

## Umbrella Target

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`.

## Plural Forms

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 Handle Plural Forms for details.

With `PLURALS_TS_FILE` you can specify the `.ts` file for the source language. This file will only contain plural forms.

## Deprecated Command Signature

Older versions of `qt_add_lupdate` took a target as the first argument. This is deprecated. Use the `SOURCE_TARGETS` argument instead.

## Examples

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` argument:

     qt_add_lupdate(
         LUPDATE_TARGET update_application_translations
         TS_FILES myapp_de.ts
         PLURALS_TS_FILE myapp_en.ts
     )