Update TDEL10n module

+ Add ability to specify a template with strings that should not be extracted.
+ Fixed detection of required programs.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 6246f2b46a)
v3.5.13-sru
Slávek Banko 6 years ago
parent e121001521
commit 7d2860cb2e
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1,6 +1,6 @@
################################################# #################################################
# #
# (C) 2018 Slávek Banko # (C) 2018-2019 Slávek Banko
# slavek (DOT) banko (AT) axis.cz # slavek (DOT) banko (AT) axis.cz
# #
# Improvements and feedback are welcome # Improvements and feedback are welcome
@ -29,7 +29,7 @@ if( NOT DEFINED KDE_XGETTEXT_EXECUTABLE )
NAMES kde-xgettext NAMES kde-xgettext
HINTS "${TDE_PREFIX}/bin" HINTS "${TDE_PREFIX}/bin"
) )
if( NOT KDE_XGETTEXT_EXECUTABLE ) if( "${KDE_XGETTEXT_EXECUTABLE}" STREQUAL "KDE_XGETTEXT_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "kde-xgettext is required but not found" ) tde_message_fatal( "kde-xgettext is required but not found" )
endif( ) endif( )
endif( ) endif( )
@ -39,7 +39,7 @@ if( NOT DEFINED XGETTEXT_EXECUTABLE )
NAMES xgettext NAMES xgettext
HINTS "${TDE_PREFIX}/bin" HINTS "${TDE_PREFIX}/bin"
) )
if( NOT XGETTEXT_EXECUTABLE ) if( "${XGETTEXT_EXECUTABLE}" STREQUAL "XGETTEXT_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "xgettext is required but not found" ) tde_message_fatal( "xgettext is required but not found" )
endif( ) endif( )
execute_process( execute_process(
@ -58,7 +58,7 @@ if( NOT DEFINED MSGUNIQ_EXECUTABLE )
NAMES msguniq NAMES msguniq
HINTS "${TDE_PREFIX}/bin" HINTS "${TDE_PREFIX}/bin"
) )
if( NOT MSGUNIQ_EXECUTABLE ) if( "${MSGUNIQ_EXECUTABLE}" STREQUAL "MSGUNIQ_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "msguniq is required but not found" ) tde_message_fatal( "msguniq is required but not found" )
endif( ) endif( )
endif( ) endif( )
@ -68,7 +68,7 @@ if( NOT DEFINED MSGCAT_EXECUTABLE )
NAMES msgcat NAMES msgcat
HINTS "${TDE_PREFIX}/bin" HINTS "${TDE_PREFIX}/bin"
) )
if( NOT MSGCAT_EXECUTABLE ) if( "${MSGCAT_EXECUTABLE}" STREQUAL "MSGCAT_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "msgcat is required but not found" ) tde_message_fatal( "msgcat is required but not found" )
endif( ) endif( )
endif( ) endif( )
@ -78,7 +78,7 @@ if( NOT DEFINED PO4A_GETTEXTIZE_EXECUTABLE )
NAMES po4a-gettextize NAMES po4a-gettextize
HINTS "${TDE_PREFIX}/bin" HINTS "${TDE_PREFIX}/bin"
) )
if( NOT PO4A_GETTEXTIZE_EXECUTABLE ) if( "${PO4A_GETTEXTIZE_EXECUTABLE}" STREQUAL "PO4A_GETTEXTIZE_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "po4a-gettextize is required but not found" ) tde_message_fatal( "po4a-gettextize is required but not found" )
endif( ) endif( )
execute_process( execute_process(
@ -92,6 +92,22 @@ if( NOT DEFINED PO4A_GETTEXTIZE_EXECUTABLE )
endif( ) endif( )
endif( ) endif( )
if( NOT DEFINED TDE_COMMON_TEXTS_POT )
get_filename_component( TDE_SOURCE_BASE "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE )
while( (NOT EXISTS "${TDE_SOURCE_BASE}/tdelibs"
OR NOT IS_DIRECTORY "${TDE_SOURCE_BASE}/tdelibs" )
AND NOT "${TDE_SOURCE_BASE}" STREQUAL "/" )
get_filename_component( TDE_SOURCE_BASE "${TDE_SOURCE_BASE}" PATH )
endwhile( )
find_file( TDE_COMMON_TEXTS_POT
NAMES tde.pot
HINTS "${TDE_SOURCE_BASE}/tdelibs" "${TDE_PREFIX}/include" "${TDE_PREFIX}/include/tde"
)
if( "${TDE_COMMON_TEXTS_POT}" STREQUAL "TDE_COMMON_TEXTS_POT-NOTFOUND" )
tde_message_fatal( "translation template with common texts not found" )
endif( )
endif( )
################################################# #################################################
##### #####
@ -142,6 +158,7 @@ endfunction( )
##### [EXCLUDES regex [regex]] ##### [EXCLUDES regex [regex]]
##### [KEYWORDS keyword [keyword]] ##### [KEYWORDS keyword [keyword]]
##### [ATTRIBUTES attrib_spec [attrib_spec]] ##### [ATTRIBUTES attrib_spec [attrib_spec]]
##### [X-POT common_texts.pot]
##### [DESTINATION directory] ##### [DESTINATION directory]
##### ) ##### )
##### #####
@ -163,6 +180,9 @@ endfunction( )
##### Use "-" if is needed to disable default keywords. ##### Use "-" if is needed to disable default keywords.
##### ATTRIBUTES determines files and specification for extractattr: ##### ATTRIBUTES determines files and specification for extractattr:
##### source_spec:element,attribute[,context][[:element,attribute[,context]]...] ##### source_spec:element,attribute[,context][[:element,attribute[,context]]...]
##### X-POT entries from common_texts.pot are not extracted
##### By default, "tde.pot" is searched for and used.
##### Use "-" to skip this.
##### DESTINATION determines directory to save translation template. ##### DESTINATION determines directory to save translation template.
##### The destination directory is determined as follows: ##### The destination directory is determined as follows:
##### a) Directory is specified as an argument. ##### a) Directory is specified as an argument.
@ -189,6 +209,7 @@ macro( tde_l10n_create_template )
unset( _keywords_add ) unset( _keywords_add )
unset( _comment ) unset( _comment )
unset( _attributes ) unset( _attributes )
unset( _exclude_pot )
unset( _pot ) unset( _pot )
unset( _directive ) unset( _directive )
set( _var _catalog ) set( _var _catalog )
@ -246,6 +267,13 @@ macro( tde_l10n_create_template )
set( _directive 1 ) set( _directive 1 )
endif( ) endif( )
# found directive "X-POT"
if( "+${_arg}" STREQUAL "+X-POT" )
unset( _exclude_pot )
set( _var _exclude_pot )
set( _directive 1 )
endif( )
# collect data # collect data
if( _directive ) if( _directive )
unset( _directive ) unset( _directive )
@ -340,6 +368,19 @@ macro( tde_l10n_create_template )
tde_message_fatal( "no source files found" ) tde_message_fatal( "no source files found" )
endif( ) endif( )
# prepare x-pot
if( NOT _exclude_pot )
set( _exclude_pot "${TDE_COMMON_TEXTS_POT}" )
endif( )
if( "${_exclude_pot}" STREQUAL "-" )
unset( _exclude_pot )
else( )
if( ${_exclude_pot} MATCHES "^[^/]" )
set( _exclude_pot "${CMAKE_CURRENT_SOURCE_DIR}/${_exclude_pot}" )
endif( )
set( _exclude_pot "-x${_exclude_pot}" )
endif( )
# prepare comment # prepare comment
if( NOT "${_comment}" STREQUAL "" ) if( NOT "${_comment}" STREQUAL "" )
if( "${_comment}" STREQUAL "-" OR "${_comment}" STREQUAL "all" ) if( "${_comment}" STREQUAL "-" OR "${_comment}" STREQUAL "all" )
@ -497,7 +538,7 @@ macro( tde_l10n_create_template )
if( _files ) if( _files )
execute_process( execute_process(
COMMAND ${KDE_XGETTEXT_EXECUTABLE} --foreign-user -C COMMAND ${KDE_XGETTEXT_EXECUTABLE} --foreign-user -C
${_comment} ${_keywords_c} -o - ${_files} ${_comment} ${_keywords_c} ${_exclude_pot} -o - ${_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _pot OUTPUT_VARIABLE _pot
) )

Loading…
Cancel
Save