Re: [Koha-patches] [PATCH] [3.4] New wrapper script for handling translation process

2010-02-17 Thread Frédéric DEMIANS
Thanks for testing and your sign-off. It could even be possible to 
include templates/preferences generation into Koha web installer or Koha 
admin. This would allow to downsize drastically Koha .tar.gz.
___
Koha-patches mailing list
Koha-patches@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-patches


Re: [Koha-patches] [PATCH] [3.4] New wrapper script for handling translation process

2010-02-17 Thread Galen Charlton
Hi Frédéric,

2010/2/17 Frédéric DEMIANS f.demi...@tamil.fr:
 Thanks for testing and your sign-off. It could even be possible to
 include templates/preferences generation into Koha web installer or Koha
 admin. This would allow to downsize drastically Koha .tar.gz.

I will be pushing this to 3.2.  However, could you send a follow-up
patch to have the license match the rest of Koha?  Koha currently uses
the GPL 2 or later, not the Lesser GPL 2.1, so please replace the
license statement with the full text as used in other Koha Perl files:

# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA  02111-1307 USA

Regards,

Galen
-- 
Galen Charlton
gmcha...@gmail.com
___
Koha-patches mailing list
Koha-patches@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-patches

Re: [Koha-patches] [PATCH] [3.4] New wrapper script for handling translation process

2010-02-17 Thread Frédéric DEMIANS

 I will be pushing this to 3.2. However, could you send a follow-up 
 patch to have the license match the rest of Koha? Koha currently uses 
 the GPL 2 or later, not the Lesser GPL 2.1, so please replace the 
 license statement with the full text as used in other Koha Perl files:

No problem.
___
Koha-patches mailing list
Koha-patches@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-patches


[Koha-patches] [PATCH] [3.4] New wrapper script for handling translation process

2010-02-16 Thread Chris Cormack
From: Frédéric Demians f.demi...@tamil.fr

Signed-off-by: Chris Cormack chr...@catalyst.net.nz
---
 misc/translator/LangInstaller.pm |  432 ++
 misc/translator/install-code.pl  |   47 
 misc/translator/install.pl   |   32 ---
 misc/translator/pref-trans   |  312 ---
 misc/translator/rebuild_lang.sh  |9 -
 misc/translator/translate|  126 +++
 6 files changed, 558 insertions(+), 400 deletions(-)
 create mode 100755 misc/translator/LangInstaller.pm
 delete mode 100755 misc/translator/install-code.pl
 delete mode 100755 misc/translator/install.pl
 delete mode 100755 misc/translator/pref-trans
 delete mode 100755 misc/translator/rebuild_lang.sh
 create mode 100755 misc/translator/translate

diff --git a/misc/translator/LangInstaller.pm b/misc/translator/LangInstaller.pm
new file mode 100755
index 000..dbad9ea
--- /dev/null
+++ b/misc/translator/LangInstaller.pm
@@ -0,0 +1,432 @@
+package LangInstaller;
+
+use strict;
+use warnings;
+
+use C4::Context;
+use YAML::Syck qw( Dump LoadFile );
+use Locale::PO;
+
+
+sub set_lang {
+my ($self, $lang) = @_;
+
+$self-{lang} = $lang;
+$self-{po_path_lang} = $self-{context}-config('intrahtdocs') .
+/prog/$lang/modules/admin/preferences;
+}
+
+
+sub new {
+my ($class, $lang, $pref_only) = @_;
+
+my $self = { };
+
+my $context  = C4::Context-new();
+$self-{context} = $context;
+$self-{path_pref_en}= $context-config('intrahtdocs') .
+   '/prog/en/modules/admin/preferences';
+set_lang( $self, $lang ) if $lang;
+$self-{pref_only}   = $pref_only;
+$self-{translator_path} = $context-config('intranetdir') . 
/misc/translator;
+$self-{path_po} = $self-{translator_path} . /po;
+$self-{po}  = {};
+
+# Get all .pref file names
+opendir my $fh, $self-{path_pref_en};
+my @pref_files = grep { /.pref/ } readdir($fh);
+close $fh;
+$self-{pref_files} = \...@pref_files;
+
+# Get all available language codes
+opendir $fh, $self-{path_po};
+my @langs =  map { ($_) =~ /(.*)-i-opac/ } 
+grep { $_ =~ /.*-opac-/ } readdir($fh);
+closedir $fh;
+$self-{langs} = \...@langs;
+
+# Map for both interfaces opac/intranet
+$self-{interface} = {
+opac = {
+dir= $context-config('opachtdocs') . '/prog',
+suffix = '-i-opac-t-prog-v-3002000.po',
+},
+intranet = {
+dir= $context-config('intrahtdocs') . '/prog',
+suffix = '-i-staff-t-prog-v-3002000.po',
+}
+};
+
+bless $self, $class;
+}
+
+
+sub po_filename {
+my $self = shift;
+
+my $context= C4::Context-new;
+my $trans_path = $context-config('intranetdir') . '/misc/translator/po';
+my $trans_file = $trans_path/ . $self-{lang} . -pref.po;
+return $trans_file;
+}
+
+
+sub po_append {
+my ($self, $id, $comment) = @_;
+my $po = $self-{po};
+my $p = $po-{$id};
+if ( $p ) {
+$p-comment( $p-comment . \n . $comment );
+}
+else {
+$po-{$id} = Locale::PO-new(
+-comment = $comment,
+-msgid   = $id,
+-msgstr  = ''
+);
+}
+}
+
+
+sub add_prefs {
+my ($self, $comment, $prefs) = @_;
+
+for my $pref ( @$prefs ) {
+my $pref_name = '';
+for my $element ( @$pref ) {
+if ( ref( $element) eq 'HASH' ) {
+$pref_name = $element-{pref};
+last;
+}
+}
+for my $element ( @$pref ) {
+if ( ref( $element) eq 'HASH' ) {
+while ( my ($key, $value) = each(%$element) ) {
+next unless $key eq 'choices';
+next unless ref($value) eq 'HASH';
+for my $ckey ( keys %$value ) {
+my $id = $self-{file} . #$pref_name#  . 
$value-{$ckey};
+$self-po_append( $id, $comment );
+}
+}
+}
+elsif ( $element ) {
+$self-po_append( $self-{file} . #$pref_name# $element, 
$comment );
+}
+}
+}
+}
+
+
+sub get_trans_text {
+my ($self, $id) = @_;
+
+my $po = $self-{po}-{$id};
+return unless $po;
+return Locale::PO-dequote($po-msgstr);
+}
+
+
+sub update_tab_prefs {
+my ($self, $pref, $prefs) = @_;
+
+for my $p ( @$prefs ) {
+my $pref_name = '';
+next unless $p;
+for my $element ( @$p ) {
+if ( ref( $element) eq 'HASH' ) {
+$pref_name = $element-{pref};
+last;
+}
+}
+for my $i ( 0...@$p-1 ) {
+my $element = $p-[$i];
+if ( ref( $element) eq 'HASH' ) {
+while ( my ($key, $value) = each(%$element) ) {
+