qt_add_translation
Qt Linguist 의 .ts 파일을 .qm 파일로 컴파일합니다.
이 명령은 Qt6 패키지의 LinguistTools 컴포넌트에 정의되어 있습니다. 다음 명령으로 패키지를 불러오세요:
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)경고: 이 함수는 더 이상 사용되지 않습니다. 대신 대상 기반 함수인 qt_add_lrelease() 또는 qt_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)에 저장됩니다. 이를 변경하려면 qt_add_translation 를 호출하기 전에 소스 .ts 파일의 속성으로 OUTPUT_LOCATION 를 설정하면 됩니다.
예를 들어, 다음 코드를 사용하면 .qm 파일이 현재 빌드 디렉터리 아래의 translations 디렉터리에 생성됩니다.
set_source_files_properties(app_en.ts app_de.ts
PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
qt_add_translation(qmFiles app_en.ts app_de.ts)예시
빌드 디렉터리 내에 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})© 2026 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.