From 7e51e261090a911004346650fab1c1d2a59ed8bb Mon Sep 17 00:00:00 2001 From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> Date: Mon, 14 Sep 2015 11:39:22 -0400 Subject: [PATCH] translations: compile and install .qm files This patch adds support via Cmake for compiling .ts translation files into the .qm files which are used at runtime. These files are installed into: <install prefix>/share/libringclient/translations dir, following the qt lib convention. The .ts files are expected to be in the translations/ dir, following the 'lrc_<language code>.ts' naming convention. Issue: #78928 Change-Id: If9c1e8520ccee58ed8ce573bd2703e029fcc7b37 --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa88fe04..a9fa1aef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,7 @@ ENDIF(NOT (${ENABLE_VIDEO} MATCHES false)) FIND_PACKAGE(Qt5Core REQUIRED) FIND_PACKAGE(Qt5DBus) +FIND_PACKAGE(Qt5LinguistTools) # translations # ADD_DEFINITIONS(-DQT_DISABLE_DEPRECATED_BEFORE=1) SET(GENERIC_LIB_VERSION "0.4.0") @@ -729,3 +730,20 @@ INSTALL( FILES ${libringclient_CONFIG_PATH} # VERSION ${GENERIC_LIB_VERSION} # COMPATIBILITY SameMajorVersion # ) + +# translations +IF( Qt5LinguistTools_FOUND ) + # translation template file + SET(TS_TEMPLATE ${CMAKE_SOURCE_DIR}/translations/lrc_en.ts) + + # get all translation files except the template + FILE(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/translations/*.ts) + LIST(REMOVE_ITEM TS_FILES ${TS_TEMPLATE}) + + # compiled .qm files + QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES}) + + ADD_CUSTOM_TARGET(translations ALL DEPENDS ${QM_FILES}) + + INSTALL(FILES ${QM_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/libringclient/translations") +ENDIF() -- GitLab