try to improve translation generation code

This commit is contained in:
Patrick von Reth 2015-07-28 12:17:05 +02:00
parent 482bcd75d9
commit 4d121989be
2 changed files with 9 additions and 11 deletions

View File

@ -8,24 +8,17 @@ if(Qt5LinguistTools_FOUND)
set(LIBSNORE_LANGS de en)
set(TS_FILES )
set( snore_i18n_content "<!DOCTYPE RCC><RCC version=\"1.0\">\n<qresource prefix=\"/lang/libsnore\">\n" )
set( snore_i18n_content "" )
foreach( lang ${LIBSNORE_LANGS} )
list(APPEND TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${lang}.ts)
set( snore_i18n_content "${snore_i18n_content}<file>${lang}.qm</file>\n" )
set( snore_i18n_content "${snore_i18n_content}\n\t\t<file>${lang}.qm</file>" )
endforeach()
set( snore_i18n_content "${snore_i18n_content}</qresource>\n</RCC>\n" )
file( WRITE ${CMAKE_BINARY_DIR}/lang/snore_i18n.qrc.in "${snore_i18n_content}" )
QT5_CREATE_TRANSLATION(libsnore_lang ${TS_FILES} ${PROJECT_SOURCE_DIR}/src)
add_custom_command(OUTPUT snore_i18n.qrc
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${CMAKE_BINARY_DIR}/lang/snore_i18n.qrc.in ${CMAKE_BINARY_DIR}/lang/snore_i18n.qrc
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(libsnore_lang_translation ALL DEPENDS ${libsnore_lang} DEPENDS snore_i18n.qrc)
configure_file(snore_i18n.qrc.in snore_i18n.qrc @ONLY)
add_custom_target(libsnore_lang_translation ALL DEPENDS ${libsnore_lang})
set(SNORE_RCS ${SNORE_RCS} ${CMAKE_BINARY_DIR}/lang/snore_i18n.qrc PARENT_SCOPE)

5
lang/snore_i18n.qrc.in Normal file
View File

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/lang/libsnore">
@snore_i18n_content@
</qresource>
</RCC>