Bugzilla – Attachment 58141 Details for
Bug 17762
Ability to translate notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17762: Add the lang parameter to C4::Letters::getletter
Bug-17762-Add-the-lang-parameter-to-C4Lettersgetle.patch (text/plain), 4.48 KB, created by
Jonathan Druart
on 2016-12-12 17:02:37 UTC
(
hide
)
Description:
Bug 17762: Add the lang parameter to C4::Letters::getletter
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-12 17:02:37 UTC
Size:
4.48 KB
patch
obsolete
>From f1f97b04bcc59568b4a606d1a04a4b787d843a5f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 8 Dec 2016 17:51:44 +0100 >Subject: [PATCH] Bug 17762: Add the lang parameter to C4::Letters::getletter > >Sponsored-by: Orex Digital >--- > C4/Letters.pm | 16 +++++++++++----- > t/db_dependent/Letters.t | 47 ++++++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 57 insertions(+), 6 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index be419d5..f814b37 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -198,8 +198,9 @@ sub GetLettersAvailableForALibrary { > } > > sub getletter { >- my ( $module, $code, $branchcode, $message_transport_type ) = @_; >+ my ( $module, $code, $branchcode, $message_transport_type, $lang ) = @_; > $message_transport_type //= '%'; >+ $lang //= 'default'; > > if ( C4::Context->preference('IndependentBranches') > and $branchcode >@@ -215,9 +216,10 @@ sub getletter { > FROM letter > WHERE module=? AND code=? AND (branchcode = ? OR branchcode = '') > AND message_transport_type LIKE ? >+ AND lang = ? > ORDER BY branchcode DESC LIMIT 1 > }); >- $sth->execute( $module, $code, $branchcode, $message_transport_type ); >+ $sth->execute( $module, $code, $branchcode, $message_transport_type, $lang ); > my $line = $sth->fetchrow_hashref > or return; > $line->{'content-type'} = 'text/html; charset="UTF-8"' if $line->{is_html}; >@@ -687,9 +689,13 @@ sub GetPreparedLetter { > my $mtt = $params{message_transport_type} || 'email'; > my $lang = $params{lang} || 'default'; > >- my $letter = getletter( $module, $letter_code, $branchcode, $mtt ) >- or warn( "No $module $letter_code letter transported by " . $mtt ), >- return; >+ my $letter = getletter( $module, $letter_code, $branchcode, $mtt, $lang ); >+ >+ unless ( $letter ) { >+ $letter = getletter( $module, $letter_code, $branchcode, $mtt, 'default' ) >+ or warn( "No $module $letter_code letter transported by " . $mtt ), >+ return; >+ } > > my $tables = $params{tables}; > my $substitute = $params{substitute}; >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 9b5c469..e45fb0f 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 80; >+use Test::More tests => 81; > use Test::MockModule; > use Test::Warn; > >@@ -491,3 +491,48 @@ is($err2, 1, "Successfully sent serial notification"); > is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification"); > is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); > } >+ >+subtest 'TranslateNotices' => sub { >+ plan tests => 3; >+ $dbh->do( >+ q| >+ INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES >+ ('test', 'code', '', 'test', 'a test', 'just a test', 'email', 'default'), >+ ('test', 'code', '', 'test', 'una prueba', 'solo una prueba', 'email', 'es-ES'); >+ | ); >+ my $substitute = {}; >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'test', >+ letter_code => 'code', >+ message_transport_type => 'email', >+ substitute => $substitute, >+ ); >+ is( >+ $letter->{title}, >+ 'a test', >+ 'GetPreparedLetter should return the default one if the lang parameter is not provided' >+ ); >+ >+ $letter = C4::Letters::GetPreparedLetter( >+ module => 'test', >+ letter_code => 'code', >+ message_transport_type => 'email', >+ substitute => $substitute, >+ lang => 'es-ES', >+ ); >+ is( $letter->{title}, 'una prueba', >+ 'GetPreparedLetter should return the required notice if it exists' ); >+ >+ $letter = C4::Letters::GetPreparedLetter( >+ module => 'test', >+ letter_code => 'code', >+ message_transport_type => 'email', >+ substitute => $substitute, >+ lang => 'fr-FR', >+ ); >+ is( >+ $letter->{title}, >+ 'a test', >+ 'GetPreparedLetter should return the default notice if the one required does not exist' >+ ); >+}; >-- >2.9.3
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 17762
:
58133
|
58134
|
58135
|
58136
|
58137
|
58138
|
58139
|
58140
|
58141
|
58525
|
59452
|
59453
|
59454
|
59455
|
59456
|
59457
|
59458
|
59459
|
59460
|
59461
|
61614
|
61615
|
61616
|
61617
|
61618
|
61619
|
61620
|
61621
|
61622
|
61623
|
61624
|
63199
|
63200
|
63201
|
63202
|
63203
|
63204
|
63205
|
63206
|
63207
|
63208
|
63209
|
63210
|
63211