Bugzilla – Attachment 9911 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]
Translate basket CSV column names using Koha::I18N
0002-Bug-8044-Translate-basket-CSV-column-names-using-Koh.patch (text/plain), 3.82 KB, created by
Julian Maurice
on 2012-06-04 12:20:35 UTC
(
hide
)
Description:
Translate basket CSV column names using Koha::I18N
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-06-04 12:20:35 UTC
Size:
3.82 KB
patch
obsolete
>From 858d21f9db4059da4b53ad698cee44e628e29c28 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 4 May 2012 14:34:13 +0200 >Subject: [PATCH 2/2] 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 | 25 ++++++++++++++++++------- > acqui/basket.pl | 4 +++- > 2 files changed, 21 insertions(+), 8 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index e856059..103cac6 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; >@@ -32,6 +31,7 @@ use C4::SQLHelper qw(InsertInTable); > > use Time::localtime; > use HTML::Entities; >+use Text::CSV::Encoded; > > use vars qw($VERSION @ISA @EXPORT); > >@@ -230,18 +230,29 @@ Export a basket as CSV > =cut > > sub GetBasketAsCSV { >- my ($basketno) = @_; >+ my ($basketno, $lh) = @_; > my $basket = GetBasket($basketno); > my @orders = GetOrders($basketno); > my $contract = GetContract($basket->{'contractnumber'}); >- my $csv = Text::CSV->new(); >+ my $csv = Text::CSV::Encoded->new(); > my $output; > >- # TODO: Translate headers >- my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp); >+ 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('Publisher code'), >+ $lh->maketext('Collection title'), >+ $lh->maketext('Notes'), >+ $lh->maketext('Quantity'), >+ $lh->maketext('RRP'), >+ ); > >- $csv->combine(@headers); >- $output = $csv->string() . "\n"; >+ $csv->combine(@headers); >+ $output = $csv->string() . "\n"; > > my @rows; > foreach my $order (@orders) { >diff --git a/acqui/basket.pl b/acqui/basket.pl >index de66891..284cf39 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')); >+ print GetBasketAsCSV($query->param('basketno'), $lh); > exit; > } elsif ($op eq 'close') { > my $confirm = $query->param('confirm') || $confirm_pref eq '2'; >-- >1.7.10 >
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