summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2018-12-09 01:14:10 +0100
committerSlávek Banko <slavek.banko@axis.cz>2018-12-09 01:14:10 +0100
commitdcb28a87ae363cc20515b0a60dc71368c27f671f (patch)
treec58ffed3f34677aeaa096da35b276c7484e028bb
parent1f90129fec23b4521c7b65c492d1e9cf9c35ca78 (diff)
downloadtde-cmake-dcb28a87ae363cc20515b0a60dc71368c27f671f.tar.gz
tde-cmake-dcb28a87ae363cc20515b0a60dc71368c27f671f.zip
Update TDEL10n module
+ Added the ability to process tips files. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--modules/TDEL10n.cmake68
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/TDEL10n.cmake b/modules/TDEL10n.cmake
index eebc1ec..30ed9ec 100644
--- a/modules/TDEL10n.cmake
+++ b/modules/TDEL10n.cmake
@@ -346,6 +346,15 @@ macro( tde_create_l10n_template )
endforeach( )
endif( )
+ # prepare tips
+ foreach( _src ${_files} )
+ if( ${_src} MATCHES "(^|/)tips$" )
+ tde_l10n_preparetips( ${_src} )
+ list( REMOVE_ITEM _files ${_src} )
+ list( APPEND _files "${_src}.tde_l10n" )
+ endif( )
+ endforeach( )
+
# pick desktop files *.desktop and *.protocol
foreach( _src ${_files} )
if( ${_src} MATCHES "\\.(desktop|protocol)(\\.cmake)?(\\.tde_l10n)?$" )
@@ -457,3 +466,62 @@ macro( tde_create_l10n_template )
endforeach( )
endmacro( )
+
+
+#################################################
+#####
+##### tde_l10n_preparetips
+#####
+##### Macro is used to prepare tips file for xgettext
+#####
+
+macro( tde_l10n_preparetips _tips )
+
+ if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_tips} )
+
+ if( POLICY CMP0007 )
+ cmake_policy( PUSH )
+ cmake_policy( SET CMP0007 NEW )
+ endif( POLICY CMP0007 )
+
+ file( READ ${CMAKE_CURRENT_SOURCE_DIR}/${_tips} _tips_html )
+ string( REGEX REPLACE "[^\n]" "" _tips_len ${_tips_html} )
+ string( LENGTH "+${_tips_len}" _tips_len )
+ unset( _tips_inside )
+ unset( _tips_l10n )
+ set( _tips_pos 0 )
+ while( _tips_pos LESS ${_tips_len} )
+ string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _tips_line "${_tips_html}" )
+ string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\2" _tips_html "${_tips_html}" )
+ math( EXPR _tips_pos "${_tips_pos}+1" )
+ string( REGEX REPLACE "\\\\" "\\\\\\\\" _tips_line "${_tips_line}" )
+ string( REGEX REPLACE "\\\"" "\\\\\"" _tips_line "${_tips_line}" )
+ if( NOT _tips_inside )
+ if( "${_tips_line}" MATCHES "<html>" )
+ set( _tips_inside 1 )
+ string( REGEX REPLACE ".*<html>" "" _tips_line "${_tips_line}" )
+ string( REGEX REPLACE "(.+)" "\"\\1\\\\n\"" _tips_line "${_tips_line}" )
+ set( _tips_line "i18n(${_tips_line}" )
+ else( )
+ set( _tips_line "" )
+ endif( )
+ else( )
+ if( "${_tips_line}" MATCHES "</html>" )
+ unset( _tips_inside )
+ string( REGEX REPLACE "</html>.*" "" _tips_line "${_tips_line}" )
+ string( REGEX REPLACE "(.+)" "\"\\1\\\\n\"" _tips_line "${_tips_line}" )
+ set( _tips_line "${_tips_line});" )
+ else( )
+ set( _tips_line "\"${_tips_line}\\n\"" )
+ endif( )
+ endif( )
+ set( _tips_l10n "${_tips_l10n}${_tips_line}\n" )
+ endwhile( )
+ file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/${_tips}.tde_l10n "${_tips_l10n}" )
+
+ if( POLICY CMP0007 )
+ cmake_policy( POP )
+ endif( POLICY CMP0007 )
+ endif( )
+
+endmacro( )