The
lconvert
command line tool filters and converts translation data files.
It supports the following file formats:
pot
- GNU Gettext localization template files
qph
- Qt Linguist Phrase Book
ts
- Qt translation sources
po
- GNU Gettext localization files
qm
- Compiled Qt translations
xlf
- XLIFF localization files
lconvert [options] <infile> [<infile>...]
Where:
options
means one or several
lconvert options
.
infile
is an input file. You can specify multiple input files.
If you specify multiple input files, they are merged with translations from later files taking precedence.
To view the latest
lconvert
help, enter:
lconvert -help
| 选项 | 动作 |
|---|---|
-h
-help
|
Display up-to-date help information and exit. |
-i <infile>
-input-file <infile>
|
Specify an input file. Use this option if
<infile>
starts with a dash. Use this option several times to merge inputs. May be
-
(standard input) for use in a pipe.
|
-o <outfile>
-output-file <outfile>
|
Specify an output file. Default is
-
(standard output).
|
-if <informat>
-input-format <format>
|
Specify input format for subsequent input files. The format is auto-detected from the file name and defaults to
ts
.
|
-of <outformat>
-output-format <outformat>
|
Specify output format. See
-if
.
|
-drop-tags <regexp>
|
Drop named extra tags when writing
TS
or
XLIFF
files. You can specify this option repeatedly.
|
-drop-translations
|
Drop existing translations and reset the status to
unfinished
. That implies
--no-obsolete
.
|
-source-language <language>[_<region>]
|
Specify/override the language of the source strings. Defaults to POSIX if not specified and the file does not name it yet. |
-target-language <language>[_<region>]
|
Specify or override the language of the translation. By default, the target language is read from the file content or guessed from the file name. |
-no-obsolete
|
Drop obsolete messages. |
-no-finished
|
Drop finished messages. |
-no-untranslated
|
Drop untranslated messages. |
-sort-contexts
|
Sort contexts in the output
TS
file alphabetically.
|
-sort-messages
|
Sort messages in a context alphabetically in
TS
文件。
|
-locations {absolute|relative|none}
|
Override how source code references are saved in
TS
files. Default is
absolute
.
|
-no-ui-lines
|
Drop line numbers from references to
UI
文件。
|
-pluralonly
|
Drop non-plural form messages. |
-verbose
|
Explain what is being done. |
To convert a single TS file to XLIFF, run the following command in the terminal:
lconvert -o myapp_de.xlf myapp_de.ts
The following command merges multiple QM files into
full_de.qm
:
lconvert -o full_de.qm qtbase_de.qm myapp_de.qm mylib_de.qm
To call
lconvert
when configuring or building your CMake project, load the
Qt6LinguistTools
package and use
$<TARGET_FILE_NAME:Qt6::lconvert>
for locating the
lconvert
可执行文件。
The following example adds a custom target
xlf_de
that converts a single TS file to XLIFF.
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
add_custom_command(
OUTPUT myapp_de.xlf
COMMAND $<TARGET_FILE:Qt6::lconvert> -o myapp_de.xlf myapp_de.ts
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/myapp_de.ts"
VERBATIM
)
add_custom_target(xlf_de
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/myapp_de.xlf"
)