[Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.19,1.20 tmpl_process3.pl,1.3,1.4

Ambrose C. LI acli at users.sourceforge.net
Sun Feb 22 09:18:30 CET 2004


Update of /cvsroot/koha/koha/misc/translator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27216

Modified Files:
	TmplTokenizer.pm tmpl_process3.pl 
Log Message:
The French character handling fix for tmpl_process3 was not checked in
for some reason.

Try to remove trailing ( in strings too.


Index: TmplTokenizer.pm
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/TmplTokenizer.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** TmplTokenizer.pm	22 Feb 2004 07:00:16 -0000	1.19
--- TmplTokenizer.pm	22 Feb 2004 08:18:27 -0000	1.20
***************
*** 443,446 ****
--- 443,482 ----
  }
  
+ sub _optimize {
+     my $this = shift;
+     my @structure = @_;
+     my $undo_trailing_blanks = sub {
+ 		for (my $i = $#structure; $i >= 0; $i -= 1) {
+ 		last if $structure[$i]->type != TmplTokenType::TEXT;
+ 		last if !blank_p($structure[$i]->string);
+ 		    push @{$this->{_queue}}, pop @structure;
+ 		}
+ 	    };
+     # FIXME: If the last token is a close tag but there are no tags
+     # FIXME: before it, drop the close tag back into the queue. This
+     # FIXME: is an ugly hack to get rid of "foo %s</h1>" type mess.
+     if (@structure >= 2
+ 	    && $structure[$#structure]->type == TmplTokenType::TAG
+ 	    && $structure[$#structure]->string =~ /^<\//s) {
+ 	my $has_other_tags_p = 0;
+ 	    printf STDERR "last token %d is type %s: %s\n", $#structure, $structure[$#structure]->type->to_string, $structure[$#structure]->string;
+ 	for (my $i = 0; $i < $#structure; $i += 1) {
+ 	    printf STDERR "token %d is type %s: %s\n", $i, $structure[$i]->type->to_string, $structure[$i]->string;
+ 	    $has_other_tags_p = 1 if $structure[$i]->type == TmplTokenType::TAG;
+ 	last if $has_other_tags_p;
+ 	}
+ 	push @{$this->{_queue}}, pop @structure unless $has_other_tags_p;
+ 	&$undo_trailing_blanks;
+     }
+     # FIXME: Do the same ugly hack for the last token being a ( or [
+     if (@structure >= 2
+ 	    && $structure[$#structure]->type == TmplTokenType::TEXT
+ 	    && $structure[$#structure]->string =~ /^[\(\[]$/) { # not )]
+ 	push @{$this->{_queue}}, pop @structure;
+ 	&$undo_trailing_blanks;
+     }
+     return @structure;
+ }
+ 
  sub next_token {
      my $this = shift;
***************
*** 486,503 ****
  		push @{$this->{_queue}}, pop @structure;
  	    }
! 	    # FIXME: If the last token is a close tag but there are no tags
! 	    # FIXME: before it, drop the close tag back into the queue. This
! 	    # FIXME: is an ugly hack to get rid of "foo %s</h1>" type mess.
! 	    if (@structure >= 2
! 		    && $structure[$#structure]->type == TmplTokenType::TAG
! 		    && $structure[$#structure]->string =~ /^<\//) {
! 		my $has_other_tags_p = 0;
! 		for (my $i = 0; $i < $#structure; $i += 1) {
! 		    $has_other_tags_p = 1
! 			    if $structure[$i]->type == TmplTokenType::TAG;
! 		last if $has_other_tags_p;
! 		}
! 		push @{$this->{_queue}}, pop @structure unless $has_other_tags_p
! 	    }
  	    if (@structure < 2) {
  		# Nothing to do
--- 522,526 ----
  		push @{$this->{_queue}}, pop @structure;
  	    }
! 	    @structure = $this->_optimize( @structure );
  	    if (@structure < 2) {
  		# Nothing to do

Index: tmpl_process3.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/tmpl_process3.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** tmpl_process3.pl	22 Feb 2004 05:18:52 -0000	1.3
--- tmpl_process3.pl	22 Feb 2004 08:18:27 -0000	1.4
***************
*** 34,37 ****
--- 34,38 ----
      my($s) = @_;
      my $key = TmplTokenizer::quote_po($s) if $s =~ /\S/;
+     $key = TmplTokenizer::charset_convert($key, $charset_in, $charset_out);
      return defined $href->{$key}
  		&& !$href->{$key}->fuzzy
***************
*** 147,150 ****
--- 148,154 ----
  VerboseWarnings::set_pedantic_mode $pedantic_p;
  
+ # try to make sure .po files are backed up (see BUGS)
+ $ENV{VERSION_CONTROL} = 't';
+ 
  # keep the buggy Locale::PO quiet if it says stupid things
  $SIG{__WARN__} = sub {
***************
*** 320,323 ****
--- 324,330 ----
  dependent commands are present.
  
+ If xgettext.pl is interrupted by the user, a corrupted po file
+ will result. This is very seriously wrong.
+ 
  Locale::PO(3) has a lot of bugs. It can neither parse nor
  generate GNU PO files properly; a couple of workarounds have





More information about the Koha-cvs mailing list