The
lrelease
command line tool produces QM files out of TS files. The QM file format is a compact binary format that the localized application uses. It provides extremely fast lookup for translations.
When building with qmake, specify the files to process at the command line or in a .pro file.
When building with CMake, use
CMake 命令
to add targets that create or update TS files and transform them into QM files. The
lrelease
tool is run with the
options
you pass to the commands when you build the target.
运行
lrelease
whenever you want to release the application, from the initial test version through to the final release version. The application does not need QM files to run, but if they are available, the application detects them and uses them automatically.
注意:
The
lrelease
tool only incorporates translations that you mark as
finished
. Otherwise, it uses the original text instead.
lrelease [options] -project project-file lrelease [options] ts-files [-qm qm-file]
Where:
options
means one or several
lrelease 选项
.
project-file
is the project configuration file.
ts-files
are the TS files to use as input for the QM files.
qm-file
is the name of the QM file to generate.
注意:
Passing .pro files to
lrelease
is deprecated. Use the
lrelease-pro
tool or the
lrelease.prf
feature when using qmake.
To view the latest help, enter:
lrelease -help
选项 | 动作 |
---|---|
-help
|
Display up-to-date help information and exit. |
-idbased
|
Use IDs instead of source strings for message keying. |
-compress
|
Compress the QM files. |
-nounfinished
|
Do not include unfinished translations. |
-removeidentical
|
If the translated text is the same as the source text, exclude the message. |
-markuntranslated <prefix>
|
If a message has no real translation, use the source text prefixed with the given string instead. |
-project <filename>
|
Name of a file containing the project's description in JSON format. You can use the
lprodump
tool to generate the file from a .pro file.
|
-silent
|
Do not explain what is being done. |
-version
|
Display the version of
lrelease
并退出。
|
When building with CMake, use CMake 命令 to add translations on targets to the CMakeLists.txt file, and then build the targets.
Select one of the following options:
qt_add_lrelease
on a target.
Build a target (for example,
app_lrelease
) to update the .qm files for it. To update the .qm files for all targets, build the target
release_translations
.
要运行
lrelease
不用指定工程文件:
lrelease.exe main_en.ts languages\main_fr.ts