Bug 6085 : utf8 fixed for xslt, and parameters, broken for utf8 included in templates
[koha_gimpoz] / misc / translator / tmpl_process3.pl
index 80325d0..15c81aa 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 );
@@ -73,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;
 }
@@ -109,6 +116,8 @@ sub text_replace (**) {
         }
         }
     } elsif (defined $t) {
+        # Quick fix to bug 4472
+        $t = "<!DOCTYPE stylesheet ["  if $t =~ /DOCTYPE stylesheet/ ;
         print $output $t;
     }
     }
@@ -218,8 +227,8 @@ my $action = shift or usage_error('You must specify an ACTION.');
 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|xsl" if !defined($type);
+# Type match defaults to *.tt plus *.inc if not specified
+$type = "tt|inc|xsl" if !defined($type);
 
 # Check the inputs for being files or directories
 for my $input (@in_files) {
@@ -385,6 +394,7 @@ if ($action eq 'create')  {
             mkdir_recursive($targetdir) unless -d $targetdir;
             print STDERR "Creating $target...\n" unless $quiet;
             open( OUTPUT, ">$target" ) || die "$target: $!\n";
+            binmode( OUTPUT, ":utf8" );
             text_replace( $h, *OUTPUT );
             close OUTPUT;
         } else {