i18n: untangle translations in the executable
- there's no need for a macro that is going to be used once, especially if there's only one place it can be called. - expand it in place and remove it from the installed CMake module
This commit is contained in:
parent
3529659629
commit
49e925ef47
@ -12,42 +12,6 @@
|
|||||||
|
|
||||||
include( CMakeParseArguments )
|
include( CMakeParseArguments )
|
||||||
|
|
||||||
# Internal macro for adding the C++ / Qt translations to the
|
|
||||||
# build and install tree. Should be called only once, from
|
|
||||||
# src/calamares/CMakeLists.txt.
|
|
||||||
macro(add_calamares_translations language)
|
|
||||||
list( APPEND CALAMARES_LANGUAGES ${ARGV} )
|
|
||||||
|
|
||||||
set( calamares_i18n_qrc_content "" )
|
|
||||||
|
|
||||||
# calamares and qt language files
|
|
||||||
foreach( lang ${CALAMARES_LANGUAGES} )
|
|
||||||
foreach( tlsource "calamares_${lang}" "tz_${lang}" )
|
|
||||||
if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
|
|
||||||
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<file>${tlsource}.qm</file>\n" )
|
|
||||||
list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set( trans_file calamares_i18n )
|
|
||||||
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
|
|
||||||
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
|
|
||||||
|
|
||||||
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
|
|
||||||
|
|
||||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
|
||||||
|
|
||||||
# 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}
|
|
||||||
)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# Installs a directory containing language-code-labeled subdirectories with
|
# Installs a directory containing language-code-labeled subdirectories with
|
||||||
# gettext data into the appropriate system directory. Allows renaming the
|
# gettext data into the appropriate system directory. Allows renaming the
|
||||||
# .mo files during install to avoid namespace clashes.
|
# .mo files during install to avoid namespace clashes.
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
# SPDX-License-Identifier: BSD-2-Clause
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
# "calamares_bin" is the main application, not to be confused with
|
|
||||||
# the target "calamares" which is the non-GUI library part.
|
|
||||||
set( calamaresSources
|
set( calamaresSources
|
||||||
main.cpp
|
main.cpp
|
||||||
CalamaresApplication.cpp
|
CalamaresApplication.cpp
|
||||||
@ -36,9 +34,44 @@ include_directories(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Translations
|
### TRANSLATIONS
|
||||||
add_calamares_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )
|
#
|
||||||
|
#
|
||||||
|
set( TS_FILES "" )
|
||||||
|
set( calamares_i18n_qrc_content "" )
|
||||||
|
|
||||||
|
# calamares and qt language files
|
||||||
|
foreach( lang ${CALAMARES_LANGUAGES} )
|
||||||
|
foreach( tlsource "calamares_${lang}" "tz_${lang}" )
|
||||||
|
if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
|
||||||
|
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<file>${tlsource}.qm</file>\n" )
|
||||||
|
list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set( trans_file calamares_i18n )
|
||||||
|
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
|
||||||
|
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
|
||||||
|
|
||||||
|
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
|
||||||
|
|
||||||
|
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||||
|
|
||||||
|
# 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}
|
||||||
|
)
|
||||||
|
|
||||||
|
### EXECUTABLE
|
||||||
|
#
|
||||||
|
# "calamares_bin" is the main application, not to be confused with
|
||||||
|
# the target "calamares" which is the non-GUI library part.
|
||||||
|
#
|
||||||
add_executable( calamares_bin ${calamaresSources} calamares.qrc ${trans_outfile} )
|
add_executable( calamares_bin ${calamaresSources} calamares.qrc ${trans_outfile} )
|
||||||
target_include_directories( calamares_bin PRIVATE ${CMAKE_SOURCE_DIR} )
|
target_include_directories( calamares_bin PRIVATE ${CMAKE_SOURCE_DIR} )
|
||||||
set_target_properties(calamares_bin
|
set_target_properties(calamares_bin
|
||||||
@ -81,6 +114,9 @@ install( FILES ${CMAKE_SOURCE_DIR}/data/images/squid.svg
|
|||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps
|
||||||
)
|
)
|
||||||
|
|
||||||
|
### TESTS
|
||||||
|
#
|
||||||
|
#
|
||||||
if( BUILD_TESTING )
|
if( BUILD_TESTING )
|
||||||
# Don't install, these are just for enable_testing
|
# Don't install, these are just for enable_testing
|
||||||
add_executable( loadmodule testmain.cpp )
|
add_executable( loadmodule testmain.cpp )
|
||||||
|
Loading…
Reference in New Issue
Block a user