From 99d63e82125c04e5ef35b012d1a43f81951dfc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Wed, 9 Jan 2019 05:00:59 +0100 Subject: Update TDEL10n module + Added ability to extract strings from documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- modules/TDEL10n.cmake | 72 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 11 deletions(-) (limited to 'modules/TDEL10n.cmake') diff --git a/modules/TDEL10n.cmake b/modules/TDEL10n.cmake index cc10e6d..c266132 100644 --- a/modules/TDEL10n.cmake +++ b/modules/TDEL10n.cmake @@ -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( ) -- cgit v1.2.1