[Koha-patches] [PATCH] Bug 4154 - Follow-up

Frédéric Demians f.demians at tamil.fr
Thu Feb 11 22:28:41 CET 2010


- Modify install-code.pl to install prefs with templates
- Update .po preferences file in order to get last 'en' preferences

For 3.4, I will do a script which will handle together the 3 .po file:
opac, intranet and preferences (and .tt files if necessary). Don't do it
now, since it will change files naming convention.
---
 misc/translator/install-code.pl  |    5 +++--
 misc/translator/po/fr-FR-pref.po |    4 ++--
 misc/translator/pref-trans       |   29 +++++++----------------------
 3 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/misc/translator/install-code.pl b/misc/translator/install-code.pl
index 6077ab0..23aa3e3 100755
--- a/misc/translator/install-code.pl
+++ b/misc/translator/install-code.pl
@@ -8,7 +8,7 @@ install-code.pl
 
 =head1 USAGE
 
-Install templates for given language codes.
+Install templates and preferences for given language codes.
 
 For example:
 
@@ -19,7 +19,6 @@ creates templates for languages: fr-FR and en-ES
 =cut
 
 
-
 sub install_code {
     my $code = shift;
     opendir(PO_DIR, "po") or die "Unable to open po directory";
@@ -37,6 +36,8 @@ sub install_code {
                   "-s po/$_";
         system $cmd;
     }
+
+    system "./pref-trans install $code";
 }
 
 
diff --git a/misc/translator/po/fr-FR-pref.po b/misc/translator/po/fr-FR-pref.po
index d28946f..c8c7fa7 100644
--- a/misc/translator/po/fr-FR-pref.po
+++ b/misc/translator/po/fr-FR-pref.po
@@ -2699,7 +2699,7 @@ msgid "searching.pref#QueryWeightFields# ranking of search results by relevance
 msgstr ""
 
 # Searching > Results Display
-msgid "searching.pref#XSLTDetailsDisplay# Show item details pages on the OPAC"
+msgid "searching.pref#XSLTDetailsDisplay# Show item details pages in the staff client"
 msgstr ""
 
 # Searching > Results Display
@@ -2711,7 +2711,7 @@ msgid "searching.pref#XSLTDetailsDisplay# using XSLT stylesheets."
 msgstr ""
 
 # Searching > Results Display
-msgid "searching.pref#XSLTResultsDisplay# Show biblio records on result page"
+msgid "searching.pref#XSLTResultsDisplay# Show biblio records on result page in the staff client"
 msgstr ""
 
 # Searching > Results Display
diff --git a/misc/translator/pref-trans b/misc/translator/pref-trans
index 4a3a1b4..9474a98 100755
--- a/misc/translator/pref-trans
+++ b/misc/translator/pref-trans
@@ -1,24 +1,6 @@
 #!/usr/bin/perl
 
 
-package PrefPo;
-
-
-sub new {
-    my ($class, $lang) = @_;
-
-    my $self           = { lang => $lang };
-    my $context        = C4::Context->new();
-    $self->{path_en}   = $context->config('intrahtdocs') .
-                         '/prog/en/modules/admin/preferences';
-    $self->{path_lang} = $context->config('intrahtdocs') .
-                         "/prog/$lang/modules/admin/preferences";
-    $self->{po}        = {};
-
-    bless $self, $class;
-}
-
-
 package Tokenizer;
 
 use strict;
@@ -105,7 +87,7 @@ sub add_prefs {
 sub get_trans_text {
     my ($self, $id) = @_;
 
-    my $po = $self->{po}->{'"'.$id.'"'};
+    my $po = $self->{po}->{$id};
     return unless $po;
     return Locale::PO->dequote($po->msgstr);
 }
@@ -155,7 +137,6 @@ sub get_po_from_prefs {
         $self->{file} = $file;
         #print Dump($pref), "\n";
         while ( my ($tab, $tab_content) = each %$pref ) {
-            print "TAB: $tab\n";
             if ( ref($tab_content) eq 'ARRAY' ) {
                 $self->add_prefs( $tab, $tab_content );
                 next;
@@ -189,7 +170,8 @@ sub init {
 sub update {
     my $self = shift;
 
-    # Get po from current .pref files
+    print "Update '", $self->{lang}, "' preferences .po file from 'en' .pref files\n";
+    # Get po from current 'en' .pref files
     $self->get_po_from_prefs();
     my $po_current = $self->{po};
 
@@ -214,7 +196,10 @@ sub install {
         print "Koha directories hierarchy for ", $self->{lang}, " must be created first\n";
         exit;
     }
-    $self->{po} = Locale::PO->load_file_ashash( $self->po_filename );
+
+    # Update the language .po file with last modified 'en' preferences
+    # and load it.
+    $self->update();
 
     chdir( $self->{path_en} );
     for my $file ( <*.pref> ) {
-- 
1.6.4.3




More information about the Koha-patches mailing list