CMake: shuffle translations macros into CMakeModules/

This commit is contained in:
Adriaan de Groot 2017-08-09 14:33:32 -04:00
parent be04b12597
commit 34c3bc6c85
3 changed files with 30 additions and 3 deletions

View File

@ -1,3 +1,6 @@
# 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} )
@ -40,3 +43,26 @@ macro(add_calamares_translations language)
)
endmacro()
# Internal macro for Python translations
#
# Translations of the Python modules that don't have their own
# lang/ subdirectories -- these are collected in top-level
# lang/python_<lang>.po
macro(add_calamares_python_translations language)
set( CALAMARES_LANGUAGES "" )
list( APPEND CALAMARES_LANGUAGES ${ARGV} )
set( TS_FILES "" ) # Actually po / mo files
foreach( lang ${CALAMARES_LANGUAGES} )
if( lang STREQUAL "en" )
message( STATUS "Skipping Python translations for en_US" )
else()
list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/python_${lang}.po;${CMAKE_SOURCE_DIR}/lang/python_${lang}.mo" )
endif()
endforeach()
install(
FILES ${TS_FILES}
DESTINATION ${CMAKE_INSTALL_DATADIR}/calamares/lang/
)
endmacro()

View File

@ -37,10 +37,8 @@ include( GNUInstallDirs )
qt5_wrap_ui( calamaresUi_H ${calamaresUi} )
#qt_add_resources( calamaresRc "../../resources.qrc" )
# Translations
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
include( CalamaresAddTranslations )
add_calamares_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )
set( final_src ${calamaresUi_H} ${calamaresSources} ${calamaresRc} ${trans_outfile} )

View File

@ -13,3 +13,6 @@ foreach( SUBDIRECTORY ${SUBDIRECTORIES} )
calamares_add_module_subdirectory( ${SUBDIRECTORY} )
endif()
endforeach()
include( CalamaresAddTranslations )
add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )