lconvert を使用する

lconvert コマンドラインツールは、翻訳データファイルのフィルタリングと変換を行います。

以下のファイル形式をサポートしています:

  • pot - GNU Gettext ローカリゼーションテンプレートファイル
  • qph -Qt Linguist フレーズブック
  • ts - Qt 翻訳ソース
  • po - GNU Gettext ローカリゼーションファイル
  • qm - コンパイルされた Qt 翻訳
  • xlf - XLIFF ローカリゼーションファイル

lconvert 構文

lconvert [options] <infile> [<infile>...]

どこで

  • options は1つまたは複数のlconvertオプションを意味する。
  • infile は入力ファイルです。複数の入力ファイルを指定できる。

複数の入力ファイルを指定した場合、それらのファイルはマージされ、後のファイルの翻訳が優先されます。

最新のlconvert ヘルプを表示するには、次のように入力します:

lconvert -help

lconvert オプション

オプション動作
-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>TS またはXLIFF ファイルを書き込む際に、名前付きの余分なタグを削除する。このオプションは繰り返し指定できます。
-drop-translations既存の翻訳を削除し、ステータスをunfinished にリセットします。 これは--no-obsolete を意味します。
-source-language <language>[_<region>]ソース文字列の言語を指定/上書きします。指定がなく、ファイルにまだ名前がない場合、デフォルトはPOSIXです。
-target-language <language>[_<region>]翻訳の言語を指定または上書きします。デフォルトでは、ターゲット言語はファイルの内容から読み込まれるか、ファイル名から推測されます。
-no-obsolete古いメッセージを削除する。
-no-finished終了したメッセージを削除する。
-no-untranslated未翻訳のメッセージを削除する。
-sort-contexts出力TS ファイルのコンテキストをアルファベット順に並べ替える。
-sort-messagesTS ファイルのコンテキスト内のメッセージをアルファベット順に並べ替える。
-locations {absolute|relative|none}TS ファイルのソース・コード参照の保存方法を上書きする。デフォルトはabsolute です。
-no-ui-linesUI ファイルへの参照から行番号を削除します。
-pluralonly複数形でないメッセージを削除する。
-verbose何が行われているかを説明する。

TSファイルをXLIFFに変換する

1つのTSファイルをXLIFFに変換するには、ターミナルで以下のコマンドを実行します:

lconvert -o myapp_de.xlf myapp_de.ts

複数のQMファイルをマージする

次のコマンドは、複数の QM ファイルをfull_de.qm にマージします:

lconvert -o full_de.qm qtbase_de.qm myapp_de.qm mylib_de.qm

CMakeでlconvertを使用する

CMake プロジェクトを設定またはビルドするときにlconvert を呼び出すには、Qt6LinguistTools パッケージをロードし、$<TARGET_FILE_NAME:Qt6::lconvert> を使用してlconvert 実行ファイルを探します。

次の例では、1つのTSファイルをXLIFFに変換するカスタムターゲットxlf_de

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"
)

© 2025 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.