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 을 추가로 설정할 수 있습니다. 사용 가능한 옵션은 릴리스 문서에서 확인할 수 있습니다.

기본적으로 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.