qt_add_translation
Qt Linguist.ts ファイルを .qm ファイルにコンパイルする。
このコマンドはQt6
パッケージのLinguistTools
コンポーネントで定義されています。でパッケージを読み込みます:
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
警告: この関数は非推奨です。代わりにターゲットベースの関数qt6_add_lreleaseまたはqt6_add_translationsの使用を検討してください。
概要
qt_add_translation(<VAR> file1.ts [file2.ts ...] [OPTIONS ...])
バージョンレスコマンドが無効になっている場合、代わりにqt6_add_translation
を使ってください。このコマンドと同じ引数セットをサポートしています。
説明
引数として渡された各.ts
ファイルに対してlrelease
を呼び出し、.qm
ファイルを生成する。生成されたファイルのパスは<VAR>
に追加される。
オプション
lrelease
が呼び出されたときに渡されるべき追加のOPTIONS
を設定することができる。設定可能なオプションはlrelease のドキュメントを参照してください。
デフォルトでは、qm
ファイルは現在のビルド・ディレクトリ (CMAKE_CURRENT_BINARY_DIR
) に置かれます。これを変更するには、ソース.ts
ファイルのプロパティとしてOUTPUT_LOCATION
を設定します。
例えば、以下のコードでは、.qm
ファイルはカレント・ビルド・ディレクトリの下のtranslations
ディレクトリに生成されます。
set_source_files_properties(app_en.ts app_de.ts PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
例
ビルド・ディレクトリにhelloworld_en.qm
,helloworld_de.qm
を生成:
qt_add_translation(qmFiles helloworld_en.ts helloworld_de.ts)
l10n
サブディレクトリにhelloworld_en.qm
,helloworld_de.qm
を生成:
set(TS_FILES helloworld_en.ts helloworld_de.ts) set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "l10n") qt_add_translation(qmFiles ${TS_FILES})
© 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.