QtLinguist

Qt Linguist, from collecting the strings to releasing the catalogues.

qm_add_translation

Add qt translation target.

qm_add_translation(<target>
    [LOCALES locales]
    [PREFIX prefix]
    [SOURCES files... | DIRECTORIES dirs... | TARGETS targets... | TS_FILES files...]
    [TS_DIR dir]
    [QM_DIR dir]
    [TS_OPTIONS options...]
    [QM_OPTIONS options...]
    [TS_DEPENDS targets...]
    [QM_DEPENDS targets...]
    [CREATE_ONCE]
)
LOCALES

language names, e.g. zh_CN en_US, must specify if SOURCES or TARGETS is specified

PREFIX

translation file prefix, default to target name

SOURCES

source files

DIRECTORIES

source directories

TARGETS

target names, the source files of which will be collected

TS_FILES

ts file names, add the specified ts file

TS_DIR

ts files destination, default to CMAKE_CURRENT_SOURCE_DIR

QM_DIR

qm files destination, default to CMAKE_CURRENT_BINARY_DIR

TS_DEPENDS

add lupdate task as a dependency to the given targets

QM_DEPENDS

add lrelease task as a dependency to the given targets

CREATE_ONCE

create translations at configure phase if not exist

Note

The Linguist tools have to be found before this is called, which qm_find_qt() is the short way to. A call made without them stops with an error saying so.

qm_import(QtLinguist)

qm_find_qt(LinguistTools)
qm_add_translation(${PROJECT_NAME}_translations
    LOCALES ja_JP zh_CN zh_TW
    PREFIX ${PROJECT_NAME}
    TARGETS ${PROJECT_NAME}
    TS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/translations
    QM_DIR ${CMAKE_CURRENT_BINARY_DIR}/translations
)

Where this page comes from

The comments in cmake/modules/QtLinguist.cmake, which is what to change.