Update TDEL10n module

+ Added ability to extract strings from documentation.

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

@ -73,6 +73,25 @@ if( NOT DEFINED MSGCAT_EXECUTABLE )
endif( )
endif( )
if( NOT DEFINED PO4A_GETTEXTIZE_EXECUTABLE )
find_program( PO4A_GETTEXTIZE_EXECUTABLE
NAMES po4a-gettextize
HINTS "${TDE_PREFIX}/bin"
)
if( NOT PO4A_GETTEXTIZE_EXECUTABLE )
tde_message_fatal( "po4a-gettextize is required but not found" )
endif( )
execute_process(
COMMAND ${PO4A_GETTEXTIZE_EXECUTABLE} --version
OUTPUT_VARIABLE _po4a_version
ERROR_VARIABLE _po4a_version
)
string( REGEX REPLACE "^po4a-gettextize[^\n]* ([^ ]*)\n.*" "\\1" _po4a_version ${_po4a_version} )
if( "${_po4a_version}" VERSION_LESS "0.45" )
tde_message_fatal( "po4a version >= 0.45 is required but found only ${_po4_version}" )
endif( )
endif( )
#################################################
#####
@ -307,16 +326,6 @@ macro( tde_l10n_create_template )
endforeach( )
# add common translator info
if( _files )
set( _translatorinfo
"i18n(\"NAME OF TRANSLATORS\", \"Your names\")\n"
"i18n(\"EMAIL OF TRANSLATORS\", \"Your emails\")\n"
)
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/_translatorinfo.tde_l10n ${_translatorinfo} )
list( INSERT _files 0 "_translatorinfo.tde_l10n" )
endif( )
# filter files by excludes
if( _excludes )
foreach( _src ${_files} )
@ -427,6 +436,34 @@ macro( tde_l10n_create_template )
endif( )
endforeach( )
# prepare documentation
foreach( _src ${_files} )
if( ${_src} MATCHES "\\.(ad|adoc|docbook|[1-8])(\\.cmake)?$" )
if( ${_src} MATCHES "\\.(ad|adoc)(\\.cmake)?$" )
set( _doc_format "asciidoc" )
elseif( ${_src} MATCHES "\\.(docbook)(\\.cmake)?$" )
set( _doc_format "docbook" )
elseif( ${_src} MATCHES "\\.([1-8])(\\.cmake)?$" )
set( _doc_format "man" )
else( )
set( _doc_format "text" )
endif( )
execute_process(
COMMAND ${PO4A_GETTEXTIZE_EXECUTABLE}
-f ${_doc_format} -m ${_src}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _potDoc
)
if( _potDoc )
string( REPLACE "Content-Type: text/plain; charset=CHARSET" "Content-Type: text/plain; charset=UTF-8" _potDoc "${_potDoc}" )
string( REPLACE "Content-Transfer-Encoding: ENCODING" "Content-Transfer-Encoding: 8bit" _potDoc "${_potDoc}" )
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/${_src}.tde_l10n "${_potDoc}" )
list( APPEND _pots ${_src}.tde_l10n )
endif( )
list( REMOVE_ITEM _files ${_src} )
endif( )
endforeach( )
# pick desktop files *.desktop and *.protocol
foreach( _src ${_files} )
if( ${_src} MATCHES "\\.(desktop|protocol)(\\.cmake)?$" )
@ -443,6 +480,19 @@ macro( tde_l10n_create_template )
endif( )
endforeach( )
# add common translator info
if( _files )
list( FIND _excludes "_translatorinfo" _translatorinfo_index )
if( "${_translatorinfo_index}" LESS 0 )
set( _translatorinfo
"i18n(\"NAME OF TRANSLATORS\", \"Your names\")\n"
"i18n(\"EMAIL OF TRANSLATORS\", \"Your emails\")\n"
)
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/_translatorinfo.tde_l10n ${_translatorinfo} )
list( INSERT _files 0 "_translatorinfo.tde_l10n" )
endif( )
endif( )
# create translation template
if( _files )
execute_process(
@ -556,7 +606,7 @@ macro( tde_l10n_create_template )
endif( _pot )
# cleanup
foreach( _file ${_files} ${_desktops} )
foreach( _file ${_files} ${_desktops} ${_pots} )
if( "${_file}" MATCHES "\\.tde_l10n[0-9]*$" )
file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/${_file} )
endif( )

Loading…
Cancel
Save