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>
(cherry picked from commit 5c09613711)
r14.0.x
Slávek Banko 6 years ago
parent ffda10ca01
commit c90656946d
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( _source )
unset( _target ) unset( _target )
unset( _context ) unset( _context )
set( _skip_properties "database|associations|populationText" )
set( _tags "[tT][eE][xX][tT]|title|string|whatsthis|tooltip|label" ) set( _tags "[tT][eE][xX][tT]|title|string|whatsthis|tooltip|label" )
set( _preserve "line-wrap" "lines-leading" "spaces-leading" "spaces-trailing" "spaces-multi" ) set( _preserve "line-wrap" "lines-leading" "spaces-leading" "spaces-trailing" "spaces-multi" )
set( _no_c_format 1 ) set( _no_c_format 1 )
@ -717,6 +718,13 @@ function( tde_l10n_prepare_xml )
set( _directive 1 ) set( _directive 1 )
endif( ) endif( )
# found directive "SKIP-PROPERTIES"
if( "+${_arg}" STREQUAL "+SKIP-PROPERTIES" )
unset( _skip_properties )
set( _var _skip_properties )
set( _directive 1 )
endif( )
# found directive "TAGS" # found directive "TAGS"
if( "+${_arg}" STREQUAL "+TAGS" ) if( "+${_arg}" STREQUAL "+TAGS" )
unset( _tags ) unset( _tags )
@ -768,6 +776,13 @@ function( tde_l10n_prepare_xml )
# prepare tags to regexp # prepare tags to regexp
string( REPLACE ";" "|" _tags "${_tags}" ) 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 # read file
file( READ ${_source} _xml_data ) file( READ ${_source} _xml_data )
@ -779,6 +794,7 @@ function( tde_l10n_prepare_xml )
unset( _xml_l10n ) unset( _xml_l10n )
unset( _xml_inside ) unset( _xml_inside )
unset( _xml_tag_empty ) unset( _xml_tag_empty )
unset( _xml_skipped_prop )
while( _xml_pos LESS ${_xml_len} ) while( _xml_pos LESS ${_xml_len} )
# pick line # pick line
string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _xml_line "${_xml_data}" ) string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _xml_line "${_xml_data}" )
@ -793,15 +809,27 @@ function( tde_l10n_prepare_xml )
unset( _xml_line_suffix ) unset( _xml_line_suffix )
unset( _xml_line_rest ) unset( _xml_line_rest )
if( NOT _xml_inside ) if( NOT _xml_inside )
if( "${_xml_line}" MATCHES "<(${_tags})[^>]*>" ) 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_inside 1 )
set( _xml_context "${_context}" ) set( _xml_context "${_context}" )
string( REGEX MATCH "<(${_tags})[^>]*>(.*)" _xml_line "${_xml_line}" ) if( "${_xml_attr}" MATCHES "[ \t]context=\"([^\"]*)\"" )
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}" ) string( REGEX REPLACE ".* context=\"([^\"]*)\".*" "\\1" _xml_context "${_xml_attr}" )
endif( ) endif( )
string( REGEX REPLACE "^<(${_tags})[^>]*>(.*)" "\\2" _xml_line "${_xml_line}" )
set( _xml_line_prefix "i18n(" ) set( _xml_line_prefix "i18n(" )
if( _no_c_format ) if( _no_c_format )
set( _xml_line_prefix "${_xml_line_prefix}/* xgettext: no-c-format */" ) set( _xml_line_prefix "${_xml_line_prefix}/* xgettext: no-c-format */" )
@ -810,6 +838,7 @@ function( tde_l10n_prepare_xml )
set( _xml_line_prefix "${_xml_line_prefix}\"${_xml_context}\", " ) set( _xml_line_prefix "${_xml_line_prefix}\"${_xml_context}\", " )
endif( ) endif( )
set( _xml_tag_empty 1 ) set( _xml_tag_empty 1 )
endif( )
else( ) else( )
set( _xml_line "" ) set( _xml_line "" )
endif( ) endif( )

Loading…
Cancel
Save