Merge pull request #2976

a00ed6a cmake: implement translations support (xiphon)
This commit is contained in:
luigi1111 2020-07-08 13:50:18 -05:00
commit 14cc1d096a
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
3 changed files with 27 additions and 2 deletions

View file

@ -487,4 +487,7 @@ 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)

View file

@ -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

View file

@ -1 +1,23 @@
qt5_add_resources(RESOURCE_FILES *.ts)
file(GLOB TS_FILES *.ts)
set(QRC "<RCC><qresource prefix=\"/\">")
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 "<file>${QM_FILE_NAME}</file>")
endforeach()
string(APPEND QRC "</qresource></RCC>")
set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
file(WRITE ${TRANSLATIONS_QRC} ${QRC})