[Po4a-commits] "po4a/lib/Locale/Po4a Xml.pm,1.48,1.49"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Sun Dec 31 15:57:01 CET 2006


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv11356/lib/Locale/Po4a

Modified Files:
	Xml.pm 
Log Message:
Initial support for comments in Xml.


Index: Xml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Xml.pm,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- Xml.pm	13 Jun 2006 23:23:34 -0000	1.48
+++ Xml.pm	31 Dec 2006 14:56:59 -0000	1.49
@@ -59,6 +59,8 @@
 #It will mantain the path from the root tag to the current one
 my @path;
 
+my @comments;
+
 sub read {
 	my ($self,$filename)=@_;
 	push @{$self->{DOCPOD}{infile}}, $filename;
@@ -343,8 +345,7 @@
 	} else {
 		die wrap_ref_mod($ref, "po4a::xml", dgettext("po4a", "Internal error: unknown type identifier '%s'."), $options->{'type'});
 	}
-
-	$text = $self->translate($text,$ref,$comment,'wrap'=>$wrap);
+	$text = $self->translate($text,$ref,$comment,'wrap'=>$wrap, comment => $options->{'comments'});
 	return $text;
 }
 
@@ -959,6 +960,7 @@
 		    and $f_extract eq \&tag_extract_comment) {
 			# Remove the content of the comments
 			($eof, @text) = $self->extract_tag($type,1);
+			push @comments, @text;
 		} else {
 			my ($tmpeof, @tag) = $self->extract_tag($type,0);
 			# Append the found inline tag
@@ -1201,6 +1203,15 @@
 	my ($self, $translate) = (shift, shift);
 	my @paragraph = @_;
 
+	my $comments;
+	while (@comments) {
+		my ($t,$l) = (shift @comments, shift @comments);
+		$comments .= "\n" if defined $comments;
+		$comments .= $t;
+	}
+	$self->pushline("<!--".$comments."-->\n") if defined $comments;
+	@comments = ();
+
 	if ( length($self->join_lines(@paragraph)) > 0 ) {
 		my $struc = $self->get_path;
 		my $options = $self->tag_in_list($struc,@{$self->{tags}});
@@ -1211,7 +1222,8 @@
 				$self->join_lines(@paragraph),
 				$paragraph[1], {
 					type=>"tag",
-					tag_options=>$options
+					tag_options=>$options,
+					comments=>$comments
 				}));
 		} else {
 			# Inform that this tag isn't translated in debug mode




More information about the Po4a-commits mailing list