diff options
-rw-r--r-- | modules/TDEL10n.cmake | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/modules/TDEL10n.cmake b/modules/TDEL10n.cmake index dfafa1b..7af4a1b 100644 --- a/modules/TDEL10n.cmake +++ b/modules/TDEL10n.cmake @@ -12,10 +12,8 @@ ##### include essential TDE macros ############## -if( NOT DEFINED MASTER_SOURCE_DIR ) - set( MASTER_SOURCE_DIR "${CMAKE_SOURCE_DIR}" ) - include( TDEMacros ) -endif( ) +set( MASTER_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ) +include( TDEMacros ) ##### verify required programs ################## @@ -154,6 +152,11 @@ endfunction( ) ##### ATTRIBUTES determines files and specification for extractattr: ##### source_spec:element,attribute[,context] ##### DESTINATION determines directory to save translation template. +##### The destination directory is determined as follows: +##### a) Directory is specified as an argument. +##### b) The variable POT_SOURCE_DIR is set. +##### c) There is a 'translations' directory. +##### d) There is a 'po' directory. ##### ##### Note: ##### Editing the _files list inside foreach( ${_files} ) below in the @@ -234,11 +237,27 @@ macro( tde_l10n_create_template ) if( NOT _catalog ) tde_message_fatal( "the name of the translation catalog is not defined" ) endif( ) + + # determine the destination directory + if( NOT _dest ) + if( POT_SOURCE_DIR ) + set( _dest ${POT_SOURCE_DIR} ) + elseif( EXISTS "${MASTER_SOURCE_DIR}/translations" ) + set( _dest "${MASTER_SOURCE_DIR}/translations/" ) + elseif( EXISTS "${MASTER_SOURCE_DIR}/po" ) + set( _dest "${MASTER_SOURCE_DIR}/po/" ) + else( ) + tde_message_fatal( "cannot determine destination directory" ) + endif( ) + endif( ) if( ${_dest} MATCHES "[^/]$" ) set( _dest "${_dest}/" ) endif( ) + if( ${_dest} MATCHES "^[^/]" ) + set( _dest "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}" ) + endif( ) - get_filename_component( _potFilename "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}${_catalog}.pot" ABSOLUTE ) + get_filename_component( _potFilename "${_dest}${_catalog}.pot" ABSOLUTE ) file( RELATIVE_PATH _potFilename ${CMAKE_SOURCE_DIR} ${_potFilename} ) message( STATUS "Create translation template ${_potFilename}" ) @@ -462,8 +481,8 @@ macro( tde_l10n_create_template ) string( REGEX REPLACE "\\.tde_l10n(:[0-9]+)" "\\1" _pot ${_pot} ) # save translation template - if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}${_catalog}.pot" ) - file( READ "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}${_catalog}.pot" _potOrig ) + if( EXISTS "${_dest}${_catalog}.pot" ) + file( READ "${_dest}${_catalog}.pot" _potOrig ) else( ) unset( _potOrig ) endif( ) @@ -472,7 +491,7 @@ macro( tde_l10n_create_template ) string( REGEX REPLACE "\n\"POT-Creation-Date: [^\"]*\"\n" "" _potNew ${_pot} ) endif( ) if( NOT _potOrig OR NOT "${_potNew}" STREQUAL "${_potOrig}" ) - file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}${_catalog}.pot" ${_pot} ) + file( WRITE "${_dest}${_catalog}.pot" ${_pot} ) endif( ) endif( _pot ) |