[Po4a-commits] "po4a/lib/Locale/Po4a Html.pm,1.11,1.12"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Sun Aug 5 16:49:17 UTC 2007
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv25403/lib/Locale/Po4a
Modified Files:
Html.pm
Log Message:
Added support for translation of the alt and title attributes.
Index: Html.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Html.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Html.pm 30 May 2005 07:05:22 -0000 1.11
+++ Html.pm 5 Aug 2007 16:49:15 -0000 1.12
@@ -111,27 +111,29 @@
} elsif ($token->[0] eq 'S') {
push @type,$token->[1];
my $text = get_tag( $token );
- if ( $token->[1] eq 'img' ) {
- my %attr = %{$token->[2]};
- for my $a (qw/title alt/) {
- my $content = $attr{$a};
- if (defined $content) {
- $content = trim($content);
- my $translated = $self->translate(
- $content,
- "FIXME:0",
- "img_$a"
- );
- $attr{$a} = $translated;
- }
+ my $tag = $token->[1];
+ my @trans_attr = (( $tag eq 'img' ) || ( $tag eq 'input' ) ||
+ ( $tag eq 'area' ) || ( $tag eq 'applet'))
+ ? qw/title alt/ : qw/title/;
+ my %attr = %{$token->[2]};
+ for my $a (@trans_attr) {
+ my $content = $attr{$a};
+ if (defined $content) {
+ $content = trim($content);
+ my $translated = $self->translate(
+ $content,
+ "FIXME:0",
+ "${tag}_$a"
+ );
+ $attr{$a} = $translated;
}
- my ($closing) = ( $text =~ /(\s*\/?>)/ );
- # reconstruct the tag from scratch
- delete $attr{'/'}; # Parser thinks closing / in XHTML is an attribute
- $text = "<img";
- $text .= " $_=\"$attr{$_}\"" foreach keys %attr;
- $text .= $closing;
}
+ my ($closing) = ( $text =~ /(\s*\/?>)/ );
+ # reconstruct the tag from scratch
+ delete $attr{'/'}; # Parser thinks closing / in XHTML is an attribute
+ $text = "<$tag";
+ $text .= " $_=\"$attr{$_}\"" foreach keys %attr;
+ $text .= $closing;
$self->pushline( $text );
} elsif ($token->[0] eq 'E') {
pop @type;
More information about the Po4a-commits
mailing list