Bugzilla – Attachment 11691 Details for
Bug 8044
Localization for Perl scripts and modules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8044: Translate basket CSV column names using Koha::I18N
0003-Bug-8044-Translate-basket-CSV-column-names-using-Koh.patch (text/plain), 6.78 KB, created by
Julian Maurice
on 2012-08-20 09:47:50 UTC
(
hide
)
Description:
Bug 8044: Translate basket CSV column names using Koha::I18N
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-08-20 09:47:50 UTC
Size:
6.78 KB
patch
obsolete
>From 8bf889616822b1bd4136b19c7703bc4eb7abdd97 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Mon, 20 Aug 2012 11:34:52 +0200 >Subject: [PATCH 3/3] Bug 8044: Translate basket CSV column names using > Koha::I18N > >This is a test case for new module Koha::I18N. >It translate CSV columns headers when you export a basket as CSV. > >To test: > - go to a basket page in staff interface with english interface > - click on "Export this basket as CSV" and check that column titles > are there and in english > - change language and click on the same button. > - column titles are still in english > - now open a terminal, go to misc/translator and run: > ./translate create LANG (e.g. fr-FR) > - translate the po misc/translator/po/LANG-messages.po with your favorite po > editor. > - go back to the navigator and click again on the Export button > - column names must be translated, according to the PO file. >--- > C4/Acquisition.pm | 79 ++++++++++++-------- > acqui/basket.pl | 4 +- > .../prog/en/modules/acqui/csv/basket.tt | 3 - > 3 files changed, 52 insertions(+), 34 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 9678ffc..785a78e 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -17,7 +17,6 @@ package C4::Acquisition; > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >- > use strict; > use warnings; > use Carp; >@@ -34,6 +33,7 @@ use C4::Templates qw(gettemplate); > > use Time::localtime; > use HTML::Entities; >+use Text::CSV::Encoded; > > use vars qw($VERSION @ISA @EXPORT); > >@@ -234,51 +234,70 @@ $cgi parameter is needed for column name translation > =cut > > sub GetBasketAsCSV { >- my ($basketno, $cgi) = @_; >+ my ($basketno, $lh) = @_; > my $basket = GetBasket($basketno); > my @orders = GetOrders($basketno); > my $contract = GetContract($basket->{'contractnumber'}); >+ my $csv = Text::CSV::Encoded->new(); >+ my $output; >+ >+ my @headers = ( >+ $lh->maketext('Contract name'), >+ $lh->maketext('Order number'), >+ $lh->maketext('Entry date'), >+ $lh->maketext('ISBN'), >+ $lh->maketext('Author'), >+ $lh->maketext('Title'), >+ $lh->maketext('Publication year'), >+ $lh->maketext('Publisher code'), >+ $lh->maketext('Collection title'), >+ $lh->maketext('Notes'), >+ $lh->maketext('Quantity'), >+ $lh->maketext('RRP'), >+ $lh->maketext('Delivery place'), >+ $lh->maketext('Billing place'), >+ ); > >- my $template = C4::Templates::gettemplate("acqui/csv/basket.tmpl", "intranet", $cgi); >+ $csv->combine(@headers); >+ $output = $csv->string() . "\n"; > > my @rows; > foreach my $order (@orders) { > my $bd = GetBiblioData( $order->{'biblionumber'} ); >- my $row = { >- contractname => $contract->{'contractname'}, >- ordernumber => $order->{'ordernumber'}, >- entrydate => $order->{'entrydate'}, >- isbn => $order->{'isbn'}, >- author => $bd->{'author'}, >- title => $bd->{'title'}, >- publicationyear => $bd->{'publicationyear'}, >- publishercode => $bd->{'publishercode'}, >- collectiontitle => $bd->{'collectiontitle'}, >- notes => $order->{'notes'}, >- quantity => $order->{'quantity'}, >- rrp => $order->{'rrp'}, >- deliveryplace => $basket->{'deliveryplace'}, >- billingplace => $basket->{'billingplace'} >- }; >- foreach(qw( >- contractname author title publishercode collectiontitle notes >- deliveryplace billingplace >- ) ) { >+ my @row = ( >+ $contract->{'contractname'}, >+ $order->{'ordernumber'}, >+ $order->{'entrydate'}, >+ $order->{'isbn'}, >+ $bd->{'author'}, >+ $bd->{'title'}, >+ $bd->{'publicationyear'}, >+ $bd->{'publishercode'}, >+ $bd->{'collectiontitle'}, >+ $order->{'notes'}, >+ $order->{'quantity'}, >+ $order->{'rrp'}, >+ $basket->{'deliveryplace'}, >+ $basket->{'billingplace'} >+ ); >+ foreach (@row) { > # Double the quotes to not be interpreted as a field end >- $row->{$_} =~ s/"/""/g if $row->{$_}; >+ $_ =~ s/"/""/g; > } >- push @rows, $row; >+ push @rows, \@row; > } > > @rows = sort { >- if(defined $a->{publishercode} and defined $b->{publishercode}) { >- $a->{publishercode} cmp $b->{publishercode}; >+ if(defined $a->[7] and defined $b->[7]) { >+ $a->[7] cmp $b->[7]; > } > } @rows; >+ foreach my $row (@rows) { >+ $csv->combine(@$row); >+ $output .= $csv->string . "\n"; >+ } > >- $template->param(rows => \@rows); >- >- return $template->output; >+ return $output; > } > > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 9b36c14..9f826f8 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -35,6 +35,7 @@ use C4::Members qw/GetMember/; #needed for permissions checking for changing ba > use C4::Items; > use C4::Suggestions; > use Date::Calc qw/Add_Delta_Days/; >+use Koha::I18N; > > =head1 NAME > >@@ -142,11 +143,12 @@ if ( $op eq 'delete_confirm' ) { > print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?basketno=' . $basket->{'basketno'} . '&op=attachbasket&booksellerid=' . $booksellerid); > # check if we have to "close" a basket before building page > } elsif ($op eq 'export') { >+ my $lh = Koha::I18N->get_handle_from_context($query, 'intranet'); > print $query->header( > -type => 'text/csv', > -attachment => 'basket' . $basket->{'basketno'} . '.csv', > ); >- print GetBasketAsCSV($query->param('basketno'), $query); >+ print GetBasketAsCSV($query->param('basketno'), $lh); > exit; > } elsif ($op eq 'close') { > my $confirm = $query->param('confirm') || $confirm_pref eq '2'; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt >deleted file mode 100644 >index 2d5c2df..0000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt >+++ /dev/null >@@ -1,3 +0,0 @@ >-Contract name,Order number,Entry date,ISBN,Author,Title,Publication year,Publisher code,Collection title,Notes,Quantity,RRP,Delivery place,Billing place >-[% FOREACH r IN rows %]"[% r.contractname %]",[% r.ordernumber %],[% r.entrydate %],[% r.isbn %],"[% r.author %]","[% r.title %]",[% r.publicationyear %],"[% r.publishercode %]","[% r.collectiontitle %]","[% r.notes %]",[% r.quantity %],[% r.rrp %],"[% r.deliveryplace %]","[% r.billingplace %]" >-[% END %] >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8044
:
9415
|
9416
|
9427
|
9449
|
9910
|
9911
|
11689
|
11690
|
11691
|
11693
|
11694
|
11695
|
11696
|
11697
|
13218
|
13219
|
13220
|
13221
|
17711
|
17712
|
17713
|
17714
|
19100
|
19101
|
19102
|
19103
|
20366
|
20367
|
20368
|
20369
|
20370
|
25964
|
25965
|
25966
|
25967