Update TDEL10n module

+ Add ability to skip the contents of selected <property> tags.
+ Fixed incorrect processing of the unpaired tags.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/14/head
Slávek Banko 6 years ago
parent 6f9d42cd99
commit 5c09613711
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -688,6 +688,7 @@ function( tde_l10n_prepare_xml )
unset( _source )
unset( _target )
unset( _context )
set( _skip_properties "database|associations|populationText" )
set( _tags "[tT][eE][xX][tT]|title|string|whatsthis|tooltip|label" )
set( _preserve "line-wrap" "lines-leading" "spaces-leading" "spaces-trailing" "spaces-multi" )
set( _no_c_format 1 )
@ -717,6 +718,13 @@ function( tde_l10n_prepare_xml )
set( _directive 1 )
endif( )
# found directive "SKIP-PROPERTIES"
if( "+${_arg}" STREQUAL "+SKIP-PROPERTIES" )
unset( _skip_properties )
set( _var _skip_properties )
set( _directive 1 )
endif( )
# found directive "TAGS"
if( "+${_arg}" STREQUAL "+TAGS" )
unset( _tags )
@ -768,6 +776,13 @@ function( tde_l10n_prepare_xml )
# prepare tags to regexp
string( REPLACE ";" "|" _tags "${_tags}" )
if( "${_skip_properties}" STREQUAL "-" )
unset( _skip_properties )
endif( )
if( DEFINED _skip_properties )
string( REPLACE ";" "|" _skip_properties "${_skip_properties}" )
set( _tags "property|${_tags}" )
endif( )
# read file
file( READ ${_source} _xml_data )
@ -779,6 +794,7 @@ function( tde_l10n_prepare_xml )
unset( _xml_l10n )
unset( _xml_inside )
unset( _xml_tag_empty )
unset( _xml_skipped_prop )
while( _xml_pos LESS ${_xml_len} )
# pick line
string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _xml_line "${_xml_data}" )
@ -793,23 +809,36 @@ function( tde_l10n_prepare_xml )
unset( _xml_line_suffix )
unset( _xml_line_rest )
if( NOT _xml_inside )
if( "${_xml_line}" MATCHES "<(${_tags})[^>]*>" )
set( _xml_inside 1 )
set( _xml_context "${_context}" )
string( REGEX MATCH "<(${_tags})[^>]*>(.*)" _xml_line "${_xml_line}" )
string( REGEX MATCH "^<(${_tags})( [^>]*)+>" _xml_attr "${_xml_line}" )
if( _xml_attr AND "${_xml_attr}" MATCHES " context=\"([^\"]*)\"" )
string( REGEX REPLACE ".* context=\"([^\"]*)\".*" "\\1" _xml_context "${_xml_attr}" )
endif( )
string( REGEX REPLACE "^<(${_tags})[^>]*>(.*)" "\\2" _xml_line "${_xml_line}" )
set( _xml_line_prefix "i18n(" )
if( _no_c_format )
set( _xml_line_prefix "${_xml_line_prefix}/* xgettext: no-c-format */" )
endif( )
if( _xml_context )
set( _xml_line_prefix "${_xml_line_prefix}\"${_xml_context}\", " )
if( _xml_skipped_prop AND "${_xml_line}" MATCHES "</property>" )
unset( _xml_skipped_prop )
string( REGEX MATCH "</property>(.*)" _xml_line "${_xml_line}" )
string( REGEX REPLACE "^</property>(.*)" "\\1" _xml_line "${_xml_line}" )
endif( )
if( NOT _xml_skipped_prop AND "${_xml_line}" MATCHES "<(${_tags})([ \t][^>]*)*>" )
string( REGEX MATCH "<(${_tags})([ \t][^>]*)*>(.*)" _xml_line "${_xml_line}" )
string( REGEX MATCH "^<(${_tags})([ \t][^>]*)*>" _xml_attr "${_xml_line}" )
string( REGEX REPLACE "^<(${_tags})([ \t][^>]*)*>(.*)" "\\3" _xml_line "${_xml_line}" )
if( "${_xml_attr}" MATCHES "^<property([ \t][^>]*)*>" AND DEFINED _skip_properties )
if( "${_xml_attr}" MATCHES "[ \t]name=\"(${_skip_properties})\"" )
set( _xml_skipped_prop 1 )
endif( )
set( _xml_line_rest "${_xml_line}" )
set( _xml_line "" )
else( )
set( _xml_inside 1 )
set( _xml_context "${_context}" )
if( "${_xml_attr}" MATCHES "[ \t]context=\"([^\"]*)\"" )
string( REGEX REPLACE ".* context=\"([^\"]*)\".*" "\\1" _xml_context "${_xml_attr}" )
endif( )
set( _xml_line_prefix "i18n(" )
if( _no_c_format )
set( _xml_line_prefix "${_xml_line_prefix}/* xgettext: no-c-format */" )
endif( )
if( _xml_context )
set( _xml_line_prefix "${_xml_line_prefix}\"${_xml_context}\", " )
endif( )
set( _xml_tag_empty 1 )
endif( )
set( _xml_tag_empty 1 )
else( )
set( _xml_line "" )
endif( )

Loading…
Cancel
Save