From e7caa309ed7e71bd3c83358e891b9c5fdfa3bab8 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 19 Apr 2011 16:03:20 +1200 Subject: [PATCH] 5917 : Working on the translation script, fixing the line breakages --- misc/translator/TTParser.pm | 6 +++--- misc/translator/TmplTokenizer.pm | 3 ++- misc/translator/xgettext.pl | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/misc/translator/TTParser.pm b/misc/translator/TTParser.pm index d5895add34..42ddaf61d2 100755 --- a/misc/translator/TTParser.pm +++ b/misc/translator/TTParser.pm @@ -39,9 +39,9 @@ sub build_tokens{ $self->{filename} = $filename; $self->handler(start => "start", "self, line, tagname, attr, text"); #signature is start( self, linenumber, tagname, hash of attributes, origional text ) $self->handler(text => "text", "self, line, text, is_cdata"); #signature is text( self, linenumber, origional text, is_cdata ) - $self->handler(end => "end", "self, line, tag, attr, text"); #signature is end( self, linenumber, tagename, origional text ) +# $self->handler(end => "end", "self, line, tag, attr, text"); #signature is end( self, linenumber, tagename, origional text ) $self->handler(declaration => "declaration", "self, line, text, is_cdata"); # declaration - $self->handler(comment => "comment", "self, line, text, is_cdata"); # comments +# $self->handler(comment => "comment", "self, line, text, is_cdata"); # comments # $self->handler(default => "default", "self, line, text, is_cdata"); # anything else $self->marked_sections(1); #treat anything inside CDATA tags as text, should really make it a TmplTokenType::CDATA $self->unbroken_text(1); #make contiguous whitespace into a single token (can span multiple lines) @@ -55,7 +55,6 @@ sub text{ my $line = shift; my $work = shift; # original text my $is_cdata = shift; - while($work){ # if there is a template_toolkit tag if( $work =~ m/\[%.*?\]/ ){ @@ -74,6 +73,7 @@ sub text{ } else { # If there is some left over work, treat it as text token my $t = TmplToken->new( $work, ($is_cdata? TmplTokenType::CDATA : TmplTokenType::TEXT), $line, $self->{filename} ); + push @tokens, $t; last; } diff --git a/misc/translator/TmplTokenizer.pm b/misc/translator/TmplTokenizer.pm index b7a93bc91c..cb4da7d207 100644 --- a/misc/translator/TmplTokenizer.pm +++ b/misc/translator/TmplTokenizer.pm @@ -324,7 +324,8 @@ sub next_token { if( $next->type == TmplTokenType::TEXT ){ push @parts, $next; } - elsif( $next->type == TmplTokenType::DIRECTIVE && $next->string =~ m/\[%\s*\w+\s*%\]/ ){ +# elsif( $next->type == TmplTokenType::DIRECTIVE && $next->string =~ m/\[%\s*\w+\s*%\]/ ){ + elsif( $next->type == TmplTokenType::DIRECTIVE ){ push @parts, $next; } elsif ( $next->type == TmplTokenType::CDATA){ diff --git a/misc/translator/xgettext.pl b/misc/translator/xgettext.pl index f2ab7ccc23..df53eba7df 100755 --- a/misc/translator/xgettext.pl +++ b/misc/translator/xgettext.pl @@ -174,7 +174,8 @@ EOF my $fmt = TmplTokenizer::_formalize( $param ); $fmt =~ s/^%/%$n\$/; if ($type == TmplTokenType::DIRECTIVE) { - $type = $param->string =~ /(TMPL_[A-Z]+)+/is? $1: 'ERROR'; + $type = "Template::Toolkit Directive"; +# $type = $param->string =~ /[%()+/is? $1: 'ERROR'; my $name = $param->string =~ /\bname=(["']?)([^\s"']+)\1/is? $2: undef; printf OUTPUT "#. %s: %s\n", $fmt, -- 2.39.5