lupdate command line tool finds translatable strings in source, header, and UI files and generates or updates TS files.
When building with qmake, specify the files to process at the command line or in a .pro file.
When building with CMake, use CMake commands to add targets that create or update TS files and transform them into QM files. The
lupdate tool is run with the options you pass to the commands when you build the target.
For more information about specifying translations in project files, see Localizing Applications.
lupdate [options] [project-file]... lupdate [options] [source-file|path|@lst-file]... -ts ts-files|@lst-file
optionsmeans one or several lupdate options.
project-fileis the project configuration file.
source-fileis a file that contains translatable strings.
pathis the path to a folder that contains translation source files.
@lst-filereads additional file names (one per line) or includepaths (one per line and prefixed with
-I) from lst-file.
ts-filesare the TS files to generate or update.
To view the latest help, enter:
|Display up-to-date help information and exit.|
|Drop all obsolete and vanished strings.|
|Process files with the given extensions, only. Use commas to separate extensions in the list. Do not use whitespace. The default value is: |
|Only include plural form messages.|
|Do not explain what is being done.|
|Do not sort contexts in TS files.|
|Do not recursively scan directories.|
|Recursively scan directories (default).|
|Look for include files in this additional location. You can specify multiple paths.|
|Specify or override the way to save source code references in TS files.|
If you do not specify the location,
|Do not record line numbers in references to UI files.|
|Disable the named merge heuristic. Can be specified multiple times.|
|Name of a file containing the project's description in JSON format. You can use the |
|Name of a .pro file. Useful for files with the .pro file syntax but some other file suffix. Projects are recursed into and merged. This option is deprecated. Use the |
|Virtual output directory for processing subsequent .pro files.|
|Trace processing .pro files. Specify twice for more verbosity.|
|Specify the language of the source strings for new files. Defaults to POSIX if not specified.|
|Specify the language of the translations for new files. If you do not specify the language, |
|Specify the output files. This overrides |
|Display the version of |
|Use clang to parse .cpp files. Otherwise, use a custom parser. This option needs a clang compilation database (|
When using qmake, set the
A directory specified on the command line takes precedence. If you do not specify a path,
|Specify one or more project root directories. Only files below a project root are considered for translation when using the |
When building with CMake, use CMake commands to add translations on targets to the CMakeLists.txt file, and then build the targets.
Select one of the following options:
- Use qt_add_translations on a target, such as app. This calls qt_add_lupdate and qt_add_lrelease.
qt_add_lupdateon a target.
Build a target (for example,
app_lupdate) to update the .ts files for it. To update the .ts files for all targets, build the target
To generate a translation file for a single QML file:
lupdate main.qml -ts main_en.ts
To make a translation file for another language, for example French, copy main_en.ts to main_fr.ts, and translate the strings in the French TS file.
lupdate processes QML files that are listed in the
RESOURCES += qml.qrc
To have all QML files processed by
lupdate application.qrc -ts myapp_en.ts
To process all QML files without using a
lupdate -extensions qml -ts myapp_en.ts
To check for translatable strings in both QML and C++ source files:
lupdate qml.qrc filevalidator.cpp -ts myapp_en.ts
To generate .ts files that will be used for English and French without specifying the languages in the project file:
lupdate qml.qrc filevalidator.cpp -ts myapp_en.ts myapp_fr.ts
Give the TS files to the translator who uses Qt Linguist to read the files and insert the translations.
The TS file format is a simple human-readable XML format that you can use with version control systems. In addition,
lupdate can process Localization Interchange File Format (XLIFF) files (
Note: Only XLIFF versions 1.1 and 1.2 are currently supported.
You can open and edit XLIFF files in Qt Linguist.
© 2023 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.