Browse Source

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>
Slávek Banko 1 month ago
parent
commit
5c09613711
Signed by: Slávek Banko <slavek.banko@axis.cz> GPG Key ID: 608F5293A04BE668
1 changed files with 45 additions and 16 deletions
  1. 45
    16
      modules/TDEL10n.cmake

+ 45
- 16
modules/TDEL10n.cmake View File

@@ -688,6 +688,7 @@ function( tde_l10n_prepare_xml )
688 688
   unset( _source )
689 689
   unset( _target )
690 690
   unset( _context )
691
+  set( _skip_properties "database|associations|populationText" )
691 692
   set( _tags "[tT][eE][xX][tT]|title|string|whatsthis|tooltip|label" )
692 693
   set( _preserve "line-wrap" "lines-leading" "spaces-leading" "spaces-trailing" "spaces-multi" )
693 694
   set( _no_c_format 1 )
@@ -717,6 +718,13 @@ function( tde_l10n_prepare_xml )
717 718
       set( _directive 1 )
718 719
     endif( )
719 720
 
721
+    # found directive "SKIP-PROPERTIES"
722
+    if( "+${_arg}" STREQUAL "+SKIP-PROPERTIES" )
723
+      unset( _skip_properties )
724
+      set( _var _skip_properties )
725
+      set( _directive 1 )
726
+    endif( )
727
+
720 728
     # found directive "TAGS"
721 729
     if( "+${_arg}" STREQUAL "+TAGS" )
722 730
       unset( _tags )
@@ -768,6 +776,13 @@ function( tde_l10n_prepare_xml )
768 776
 
769 777
   # prepare tags to regexp
770 778
   string( REPLACE ";" "|" _tags "${_tags}" )
779
+  if( "${_skip_properties}" STREQUAL "-" )
780
+    unset( _skip_properties )
781
+  endif( )
782
+  if( DEFINED _skip_properties )
783
+    string( REPLACE ";" "|" _skip_properties "${_skip_properties}" )
784
+    set( _tags "property|${_tags}" )
785
+  endif( )
771 786
 
772 787
   # read file
773 788
   file( READ ${_source} _xml_data )
@@ -779,6 +794,7 @@ function( tde_l10n_prepare_xml )
779 794
   unset( _xml_l10n )
780 795
   unset( _xml_inside )
781 796
   unset( _xml_tag_empty )
797
+  unset( _xml_skipped_prop )
782 798
   while( _xml_pos LESS ${_xml_len} )
783 799
     # pick line
784 800
     string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _xml_line "${_xml_data}" )
@@ -793,23 +809,36 @@ function( tde_l10n_prepare_xml )
793 809
       unset( _xml_line_suffix )
794 810
       unset( _xml_line_rest )
795 811
       if( NOT _xml_inside )
796
-        if( "${_xml_line}" MATCHES "<(${_tags})[^>]*>" )
797
-          set( _xml_inside 1 )
798
-          set( _xml_context "${_context}" )
799
-          string( REGEX MATCH "<(${_tags})[^>]*>(.*)" _xml_line "${_xml_line}" )
800
-          string( REGEX MATCH "^<(${_tags})( [^>]*)+>" _xml_attr "${_xml_line}" )
801
-          if( _xml_attr AND "${_xml_attr}" MATCHES " context=\"([^\"]*)\"" )
802
-            string( REGEX REPLACE ".* context=\"([^\"]*)\".*" "\\1" _xml_context "${_xml_attr}" )
803
-          endif( )
804
-          string( REGEX REPLACE "^<(${_tags})[^>]*>(.*)" "\\2" _xml_line "${_xml_line}" )
805
-          set( _xml_line_prefix "i18n(" )
806
-          if( _no_c_format )
807
-            set( _xml_line_prefix "${_xml_line_prefix}/* xgettext: no-c-format */" )
808
-          endif( )
809
-          if( _xml_context )
810
-            set( _xml_line_prefix "${_xml_line_prefix}\"${_xml_context}\", " )
812
+        if( _xml_skipped_prop AND "${_xml_line}" MATCHES "</property>" )
813
+          unset( _xml_skipped_prop )
814
+          string( REGEX MATCH "</property>(.*)" _xml_line "${_xml_line}" )
815
+          string( REGEX REPLACE "^</property>(.*)" "\\1" _xml_line "${_xml_line}" )
816
+        endif( )
817
+        if( NOT _xml_skipped_prop AND "${_xml_line}" MATCHES "<(${_tags})([ \t][^>]*)*>" )
818
+          string( REGEX MATCH "<(${_tags})([ \t][^>]*)*>(.*)" _xml_line "${_xml_line}" )
819
+          string( REGEX MATCH "^<(${_tags})([ \t][^>]*)*>" _xml_attr "${_xml_line}" )
820
+          string( REGEX REPLACE "^<(${_tags})([ \t][^>]*)*>(.*)" "\\3" _xml_line "${_xml_line}" )
821
+          if( "${_xml_attr}" MATCHES "^<property([ \t][^>]*)*>" AND DEFINED _skip_properties )
822
+            if( "${_xml_attr}" MATCHES "[ \t]name=\"(${_skip_properties})\"" )
823
+              set( _xml_skipped_prop 1 )
824
+            endif( )
825
+            set( _xml_line_rest "${_xml_line}" )
826
+            set( _xml_line "" )
827
+          else( )
828
+            set( _xml_inside 1 )
829
+            set( _xml_context "${_context}" )
830
+            if( "${_xml_attr}" MATCHES "[ \t]context=\"([^\"]*)\"" )
831
+              string( REGEX REPLACE ".* context=\"([^\"]*)\".*" "\\1" _xml_context "${_xml_attr}" )
832
+            endif( )
833
+            set( _xml_line_prefix "i18n(" )
834
+            if( _no_c_format )
835
+              set( _xml_line_prefix "${_xml_line_prefix}/* xgettext: no-c-format */" )
836
+            endif( )
837
+            if( _xml_context )
838
+              set( _xml_line_prefix "${_xml_line_prefix}\"${_xml_context}\", " )
839
+            endif( )
840
+            set( _xml_tag_empty 1 )
811 841
           endif( )
812
-          set( _xml_tag_empty 1 )
813 842
         else( )
814 843
           set( _xml_line "" )
815 844
         endif( )

Loading…
Cancel
Save