Bug 4472 - Missing / in img tags breaking xslt (and other img tags)
[srvgit] / misc / translator / tmpl_process3.pl
index b543a91..af0cde1 100755 (executable)
@@ -12,6 +12,7 @@ using gettext-compatible translation files
 =cut
 
 use strict;
+#use warnings; FIXME - Bug 2505
 use Getopt::Long;
 use Locale::PO;
 use File::Temp qw( :POSIX );
@@ -50,11 +51,12 @@ sub text_replace_tag ($$) {
     # value [tag=input], meta
     my $tag = lc($1) if $t =~ /^<(\S+)/s;
     my $translated_p = 0;
-    for my $a ('alt', 'content', 'title', 'value') {
+    for my $a ('alt', 'content', 'title', 'value','label') {
     if ($attr->{$a}) {
+        next if $a eq 'label' && $tag ne 'optgroup';
         next if $a eq 'content' && $tag ne 'meta';
         next if $a eq 'value' && ($tag ne 'input'
-        || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|text|submit)$/)); # FIXME
+        || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/)); # FIXME
         my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
         if ($val =~ /\S/s) {
         my $s = find_translation($val);
@@ -72,10 +74,16 @@ sub text_replace_tag ($$) {
             sprintf(' %s=%s', $_, $attr->{$_}->[2]) #FIXME
         } sort {
             $attr->{$a}->[3] <=> $attr->{$b}->[3] #FIXME
-        } keys %$attr)
-        . '>';
-    } else {
-    $it = $t;
+        } keys %$attr);
+       if ($tag eq 'img'){
+           $it .= ' />';
+       }
+       else {      
+           $it .= ' >';
+       }
+    } 
+    else {
+        $it = $t;
     }
     return $it;
 }
@@ -218,7 +226,7 @@ usage_error('You must at least specify input and string list filenames.')
     if !@in_files || !defined $str_file;
 
 # Type match defaults to *.tmpl plus *.inc if not specified
-$type = "tmpl|inc|js|xsl|def" if !defined($type);
+$type = "tmpl|inc|xsl" if !defined($type);
 
 # Check the inputs for being files or directories
 for my $input (@in_files) {