mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[libcalamares] Refactor translations-for-a-test CMake code
- turn the translations-QRC phase into a function, just in case other tests need translations as well. - This CMake code might work as the base of translation-wrangling for plugins (externally).
This commit is contained in:
parent
cfbe722350
commit
1af8796b2b
1 changed files with 36 additions and 16 deletions
|
@ -215,29 +215,49 @@ calamares_add_test(
|
|||
${geoip_src}
|
||||
)
|
||||
|
||||
# Build up translations for this one test
|
||||
set( trans_file "localetest" )
|
||||
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
|
||||
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
|
||||
set( calamares_i18n_qrc_content "<file>localetest_nl.qm</file>" )
|
||||
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
|
||||
function ( calamares_qrc_translations basename )
|
||||
set( NAME ${ARGV0} )
|
||||
set( options "" )
|
||||
set( oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE )
|
||||
set( multiValueArgs LANGUAGES )
|
||||
cmake_parse_arguments( _qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
qt5_add_translation(QM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/testdata/localetest_nl.ts")
|
||||
if( NOT _qrt_OUTPUT_VARIABLE )
|
||||
set( _qrt_OUTPUT_VARIABLE "qrc_translations_${basename}" )
|
||||
endif()
|
||||
|
||||
# Run the resource compiler (rcc_options should already be set)
|
||||
add_custom_command(
|
||||
OUTPUT ${trans_outfile}
|
||||
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
|
||||
ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile}
|
||||
MAIN_DEPENDENCY ${trans_infile}
|
||||
DEPENDS ${QM_FILES}
|
||||
)
|
||||
set( translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc )
|
||||
set( translations_qrc_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${basename}.cxx )
|
||||
|
||||
# Must use this variable name because of the @ substitution
|
||||
set( calamares_i18n_qrc_content "" )
|
||||
set( calamares_i18n_ts_filelist "" )
|
||||
foreach( lang ${_qrt_LANGUAGES} )
|
||||
string( APPEND calamares_i18n_qrc_content "<file>${basename}_${lang}.qm</file>" )
|
||||
list( APPEND calamares_i18n_ts_filelist "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${basename}_${lang}.ts" )
|
||||
endforeach()
|
||||
|
||||
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${translations_qrc_infile} @ONLY )
|
||||
qt5_add_translation(QM_FILES ${calamares_i18n_ts_filelist})
|
||||
|
||||
# Run the resource compiler (rcc_options should already be set)
|
||||
add_custom_command(
|
||||
OUTPUT ${translations_qrc_outfile}
|
||||
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
|
||||
ARGS ${rcc_options} --format-version 1 -name ${basename} -o ${translations_qrc_outfile} ${translations_qrc_infile}
|
||||
MAIN_DEPENDENCY ${translations_qrc_infile}
|
||||
DEPENDS ${QM_FILES}
|
||||
)
|
||||
|
||||
set( ${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
calamares_qrc_translations( localetest OUTPUT_VARIABLE localetest_qrc SUBDIRECTORY testdata LANGUAGES nl )
|
||||
calamares_add_test(
|
||||
libcalamareslocaletest
|
||||
SOURCES
|
||||
locale/Tests.cpp
|
||||
${trans_outfile}
|
||||
${localetest_qrc}
|
||||
)
|
||||
|
||||
calamares_add_test(
|
||||
|
|
Loading…
Add table
Reference in a new issue