diff --git a/modules/TDEL10n.cmake b/modules/TDEL10n.cmake index 8ab4a7a..8c2caf8 100644 --- a/modules/TDEL10n.cmake +++ b/modules/TDEL10n.cmake @@ -83,6 +83,16 @@ if( NOT DEFINED MSGUNIQ_EXECUTABLE ) endif( ) endif( ) +if( NOT DEFINED MSGCAT_EXECUTABLE ) + find_program( MSGCAT_EXECUTABLE + NAMES msgcat + HINTS "${TDE_PREFIX}/bin" + ) + if( NOT MSGCAT_EXECUTABLE ) + tde_message_fatal( "msgcat is required but not found" ) + endif( ) +endif( ) + ################################################# ##### @@ -173,6 +183,7 @@ macro( tde_l10n_create_template ) unset( _files ) unset( _rcs ) unset( _desktops ) + unset( _pots ) unset( _dest ) unset( _keywords ) unset( _attributes ) @@ -399,6 +410,14 @@ macro( tde_l10n_create_template ) endif( ) endforeach( ) + # pick pot files *.pot + foreach( _src ${_files} ) + if( ${_src} MATCHES "\\.pot(\\.cmake)?(\\.tde_l10n)?$" ) + list( APPEND _pots ${_src} ) + list( REMOVE_ITEM _files ${_src} ) + endif( ) + endforeach( ) + # create translation template if( _files ) execute_process( @@ -439,9 +458,10 @@ macro( tde_l10n_create_template ) file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp ${_pot} ) file( APPEND ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp ${_potDesktop} ) execute_process( - COMMAND ${MSGUNIQ_EXECUTABLE} - INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp - OUTPUT_VARIABLE _pot + COMMAND ${MSGUNIQ_EXECUTABLE} --use-first + INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE _pot ) file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp ) else( ) @@ -454,6 +474,21 @@ macro( tde_l10n_create_template ) endif( ) endif( ) + # merge additional pot files + if( _pots ) + file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp ${_pot} ) + execute_process( + COMMAND ${MSGCAT_EXECUTABLE} --use-first extracted-pot.tmp ${_pots} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE _pot + ) + file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp ) + + # set charset and encoding headers + string( REPLACE "Content-Type: text/plain charset=CHARSET" "Content-Type: text/plain charset=UTF-8" _pot ${_pot} ) + string( REPLACE "Content-Transfer-Encoding: ENCODING" "Content-Transfer-Encoding: 8bit" _pot ${_pot} ) + endif( ) + # finalize translation template if( _pot )