@ -1,3 +1,5 @@
include ( CMakeParseArguments )
# I n t e r n a l m a c r o f o r a d d i n g t h e C + + / Q t t r a n s l a t i o n s t o t h e
# b u i l d a n d i n s t a l l t r e e . S h o u l d b e c a l l e d o n l y o n c e , f r o m
# s r c / c a l a m a r e s / C M a k e L i s t s . t x t .
@ -52,20 +54,63 @@ macro(add_calamares_python_translations language)
set ( CALAMARES_LANGUAGES "" )
list ( APPEND CALAMARES_LANGUAGES ${ ARGV } )
set ( TS_FILES "" ) # A c t u a l l y p o / m o f i l e s
foreach ( lang ${ CALAMARES_LANGUAGES } )
install_calamares_gettext_translations ( python
S O U R C E _ D I R $ { C M A K E _ S O U R C E _ D I R } / l a n g / p y t h o n
F I L E N A M E p y t h o n . m o
R E N A M E c a l a m a r e s - p y t h o n . m o
)
endmacro ( )
# I n s t a l l s a d i r e c t o r y c o n t a i n i n g l a n g u a g e - c o d e - l a b e l e d s u b d i r e c t o r i e s w i t h
# g e t t e x t d a t a i n t o t h e a p p r o p r i a t e s y s t e m d i r e c t o r y . A l l o w s r e n a m i n g t h e
# . m o f i l e s d u r i n g i n s t a l l t o a v o i d n a m e s p a c e c l a s h e s .
#
# install_calamares_gettext_translations (
# N A M E < n a m e o f m o d u l e , f o r h u m a n u s e >
# S O U R C E _ D I R p a t h / t o / l a n g
# F I L E N A M E < n a m e o f f i l e . m o >
# [ R E N A M E < n e w - n a m e o f . m o > ]
# )
#
# F o r a l l o f the ( global ) t r a n s l a t i o n l a n g u a g e s e n a b l e d f o r C a l a m a r e s ,
# t r y i n s t a l l i n g $ S O U R C E _ D I R / $ l a n g / L C _ M E S S A G E S / < f i l e n a m e > . m o i n t o t h e
# s y s t e m g e t t e x t d a t a directory ( e.g. share/locale/ ) , p o s s i b l y r e n a m i n g
# f i l e n a m e . m o t o r e n a m e d . m o i n t h e p r o c e s s .
function ( install_calamares_gettext_translations )
# p a r s e arguments ( name needs to be saved before passing ARGN into the macro )
set ( NAME ${ ARGV0 } )
set ( oneValueArgs NAME SOURCE_DIR FILENAME RENAME )
cmake_parse_arguments ( TRANSLATION "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
if ( NOT TRANSLATION_NAME )
set ( TRANSLATION_NAME ${ NAME } )
endif ( )
if ( NOT TRANSLATION_FILENAME )
set ( TRANSLATION_FILENAME "${TRANSLATION_NAME}.mo" )
endif ( )
if ( NOT TRANSLATION_RENAME )
set ( TRANSLATION_RENAME "${TRANSLATION_FILENAME}" )
endif ( )
message ( STATUS "Installing gettext translations for ${TRANSLATION_NAME}" )
message ( STATUS " Installing ${TRANSLATION_FILENAME} from ${TRANSLATION_SOURCE_DIR}" )
set ( TRANSLATION_NAME "${NAME}" )
set ( INSTALLED_TRANSLATIONS "" )
foreach ( lang ${ CALAMARES_TRANSLATION_LANGUAGES } ) # G l o b a l
set ( lang_mo "${TRANSLATION_SOURCE_DIR}/${lang}/LC_MESSAGES/${TRANSLATION_FILENAME}" )
message ( STATUS " Examining ${lang_mo}" )
if ( lang STREQUAL "en" )
message ( STATUS "Skipping Python translations for en_US" )
else ( )
list ( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/python/${lang}/LC_MESSAGES/python.po;${CMAKE_SOURCE_DIR}/lang/python/${lang}/LC_MESSAGES/python.mo" )
message ( STATUS " Skipping ${TRANSLATION_NAME} translations for en_US" )
else ( EXISTS ${ lang_mo } )
list ( APPEND INSTALLED_LANGUAGES "${lang}" )
install (
F I L E S $ { l a n g _ m o }
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L O C A L E D I R } / $ { l a n g } / L C _ M E S S A G E S /
R E N A M E $ { T R A N S L A T I O N _ R E N A M E }
)
# T O D O : m a k e t r a n s l a t i o n s a v a i l a b l e i n b u i l d d i r t o o , f o r
# t r a n s l a t i o n w h e n r u n n i n g c a l a m a r e s - d f r o m b u i l d d i r .
endif ( )
endforeach ( )
file ( MAKE_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /_lang )
file ( COPY ${ CMAKE_SOURCE_DIR } /lang/python DESTINATION ${ CMAKE_CURRENT_BINARY_DIR } /_lang )
install (
F I L E S $ { T S _ F I L E S }
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A D I R } / c a l a m a r e s / l a n g /
)
endmacro ( )
endfunction ( )