[Koha-patches] [PATCH] Fixes translated boolean syspref inversion

Frédéric Demians f.demians at tamil.fr
Tue Mar 2 22:20:27 CET 2010


For example, for NoZebra syspref in French 'no' means 'yes' and 'yes'
mean 'no'. It applies to all boolean sysprefs.

The bugs comes from a tricky issue with how YAML parser interprets
yes/no value in hash's keys. Those values are surrounded automatically
with double quotes which causes translated syspref installation to fail.

I found no other solution than switching from YAML::Syck to YAML::XS.
I've seen than this dependency has been removed recently but...
---
 misc/translator/LangInstaller.pm |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/misc/translator/LangInstaller.pm b/misc/translator/LangInstaller.pm
index dc6d125..497bd57 100755
--- a/misc/translator/LangInstaller.pm
+++ b/misc/translator/LangInstaller.pm
@@ -21,7 +21,7 @@ use strict;
 use warnings;
 
 use C4::Context;
-use YAML::Syck qw( Dump LoadFile );
+use YAML::XS qw( Dump LoadFile );
 use Locale::PO;
 
 
@@ -128,7 +128,7 @@ sub add_prefs {
                 }
             }
             elsif ( $element ) {
-                $self->po_append( $self->{file} . "#$pref_name# $element", $comment );
+                $self->po_append( $self->{file} . "#$pref_name# $element", $comment ) if defined $pref_name;
             }
         }
     }
@@ -170,7 +170,7 @@ sub update_tab_prefs {
                 }
             }
             elsif ( $element ) {
-                my $text = $self->get_trans_text( $self->{file} . "#$pref_name# $element" );
+                my $text = $self->get_trans_text( $self->{file} . "#$pref_name# $element" ) if defined $pref_name;
                 $p->[$i] = $text if $text;
             }
         }
@@ -264,7 +264,9 @@ sub install_prefs {
         my $file_trans = $self->{po_path_lang} . "/$file";
         print "Write $file\n";
         open my $fh, ">", $file_trans;
-        print $fh Dump($pref);
+        my $out = Dump($pref);
+        utf8::decode($out);
+        print $fh $out;
     }
 }
 
-- 
1.6.4.3




More information about the Koha-patches mailing list