Bugzilla – Attachment 63206 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.65 KB, created by
Nick Clemens (kidclamp)
on 2017-05-05 20:21:59 UTC
(
hide
)
Description:
Bug 17762: Add the lang parameter to C4::Letters::getletter
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-05-05 20:21:59 UTC
Size:
4.65 KB
patch
obsolete
>From 4daf1f894dacece868ba94f11aa61f7c6a096eab 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 > >Signed-off-by: Hugo Agud <hagud@orex.es> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Letters.pm | 16 +++++++++++----- > t/db_dependent/Letters.t | 48 +++++++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 58 insertions(+), 6 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 5542010..9a5afb2 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}; >@@ -688,9 +690,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 33f7af4..beecb94 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 => 81; >+use Test::More tests => 82; > use Test::MockModule; > use Test::Warn; > >@@ -534,6 +534,52 @@ is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notificatio > 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' >+ ); >+}; >+ > subtest 'SendQueuedMessages' => sub { > plan tests => 1; > t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); >-- >2.1.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 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