Update TDEL10n module

+ Added options for determining the destination directory.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 3779b941ef)
r14.0.x
Slávek Banko 6 years ago
parent cc3cab06b7
commit 2c5d5794cc
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -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 )

Loading…
Cancel
Save