From a00ed6a75aef82084e42297f63619a064ad5f066 Mon Sep 17 00:00:00 2001 From: xiphon Date: Tue, 30 Jun 2020 17:07:35 +0000 Subject: [PATCH] cmake: implement translations support --- CMakeLists.txt | 3 +++ src/CMakeLists.txt | 2 +- translations/CMakeLists.txt | 24 +++++++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fd37d60..ff99036b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -441,6 +441,9 @@ if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED) endif() endif() +add_subdirectory(translations) +get_directory_property(TRANSLATIONS_QRC DIRECTORY translations DEFINITION TRANSLATIONS_QRC) + add_subdirectory(src) # Required to make wallet_merged build before the gui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb83cb0c..1e286e74 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ add_subdirectory(model) add_subdirectory(openpgp) add_subdirectory(zxcvbn-c) -qt5_add_resources(RESOURCES ../qml.qrc) +qt5_add_resources(RESOURCES ../qml.qrc ${TRANSLATIONS_QRC}) # Compile source files (.h/.cpp) file(GLOB SOURCE_FILES diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt index fe193ca1..8f1c0bc6 100644 --- a/translations/CMakeLists.txt +++ b/translations/CMakeLists.txt @@ -1 +1,23 @@ -qt5_add_resources(RESOURCE_FILES *.ts) +file(GLOB TS_FILES *.ts) + +set(QRC "") +foreach(TS_FILE ${TS_FILES}) + get_filename_component(QM_FILE ${TS_FILE} NAME_WE) + set(QM_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QM_FILE}.qm) + + execute_process(COMMAND lrelease -compress -nounfinished -removeidentical ${TS_FILE} -qm ${QM_FILE} + RESULT_VARIABLE RET + OUTPUT_VARIABLE OUT + ERROR_VARIABLE ERR + ) + if(RET) + message(FATAL_ERROR "${TS_FILE}: lrelease returned non-zero exit code: ${RET} ${OUT} ${ERR}") + endif() + + get_filename_component(QM_FILE_NAME ${QM_FILE} NAME) + string(APPEND QRC "${QM_FILE_NAME}") +endforeach() +string(APPEND QRC "") + +set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) +file(WRITE ${TRANSLATIONS_QRC} ${QRC})