Bugzilla – Attachment 166686 Details for
Bug 36815
Add the option to 'Reset to default' in the notices editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36815: (follow-up) Fix logic for new languages
Bug-36815-follow-up-Fix-logic-for-new-languages.patch (text/plain), 4.49 KB, created by
Martin Renvoize (ashimema)
on 2024-05-14 12:28:06 UTC
(
hide
)
Description:
Bug 36815: (follow-up) Fix logic for new languages
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-05-14 12:28:06 UTC
Size:
4.49 KB
patch
obsolete
>From 1be71763110d31b45ff2b55c6ccd820f49fc62b0 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 10 May 2024 13:15:39 +0100 >Subject: [PATCH] Bug 36815: (follow-up) Fix logic for new languages > >If a notice doesn't already have any data in it we weren't able to use >the object to lookup the sample.. with this patch we now always load the >samples if they exist for each installed and enabled language, >regardless of whether there's already a notice stored in that language. > >Test plan >1. Install Spanish by running koha-translate --install es-ES from inside > the kohashell >2. restart all >3. Set TranslateNotices to Allow >4. Verify that the Spanish-language sample_notices.yml exists >5. Open a notice that has at least one Spanish default notice defined >6. Confirm you see the 'View default' button for the spanish notice and > that the displayed notice is indeed the spanish translation >--- > tools/letter.pl | 45 +++++++++++++++++++++++++++------------------ > 1 file changed, 27 insertions(+), 18 deletions(-) > >diff --git a/tools/letter.pl b/tools/letter.pl >index dbe84aa26cb..20472c18102 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -159,7 +159,7 @@ sub add_form { > > my $message_transport_types = GetMessageTransportTypes(); > my $templates = { map { $_ => { message_transport_type => $_ } } sort @$message_transport_types }; >- my %letters = ( default => { templates => $templates } ); >+ my %letters = ( default => { templates => {%$templates} } ); > > my $translated_languages = C4::Languages::getTranslatedLanguages( > 'opac', >@@ -189,19 +189,20 @@ sub add_form { > $template->param( default_language => $default_language ); > if ($letters) { > $template->param( >- modify => 1, >- code => $code, >+ modify => 1, >+ code => $code, > ); > my $first_flag_name = 1; > my $lang; > > # The letter name is contained into each mtt row. > # So we can only sent the first one to the template. >- for my $letter ( @$letters ) { >+ for my $letter (@$letters) { >+ > # The letter_name > if ( $first_flag_name and $letter->{name} ) { > $template->param( >- letter_name=> $letter->{name}, >+ letter_name => $letter->{name}, > ); > $first_flag_name = 0; > } >@@ -217,23 +218,31 @@ sub add_form { > }; > > my $lang = $letter->{lang}; >- my $mtt = $letter->{message_transport_type}; >- $letters{ $lang }{templates}{$mtt} = { >+ my $mtt = $letter->{message_transport_type}; >+ $letters{$lang}{templates}{$mtt} = { > message_transport_type => $letter->{message_transport_type}, >- is_html => $letter->{is_html}, >- updated_on => $letter->{updated_on}, >- title => $letter->{title}, >- content => $letter->{content} // '', >- tt_error => $letter->{tt_error}, >+ is_html => $letter->{is_html}, >+ updated_on => $letter->{updated_on}, >+ title => $letter->{title}, >+ content => $letter->{content} // '', >+ tt_error => $letter->{tt_error}, > }; >- $letters{ $lang }{params} = $letter; >+ $letters{$lang}{params} = $letter; >+ } > >- my $object = Koha::Notice::Templates->find( { id => $letter->{id} } ); >- $letters{ $lang }{templates}{$mtt}{sample} = $object->get_default; >- $letters{ $lang }{templates}{$mtt}{id} = $letter->{id}; >+ # Fetch sample notices >+ for my $lang_key ( keys %letters ) { >+ for my $mtt_key ( keys %{ $letters{$lang_key}{templates} } ) { >+ my $object = Koha::Notice::Template->new( >+ { module => $module, code => $code, message_transport_type => $mtt_key, lang => $lang_key } ); >+ my $sample = $object->get_default; >+ my $template = { %{ $letters{$lang_key}{templates}{$mtt_key} } }; >+ $template->{sample} = $sample; >+ $template->{id} = lc( "$module" . "_" . $code . "_" . $mtt_key . "_" . $lang_key ); >+ $letters{$lang_key}{templates}{$mtt_key} = $template; >+ } > } >- } >- else { >+ } else { > $template->param( adding => 1 ); > } > >-- >2.45.0
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 36815
:
166429
|
166430
|
166449
|
166450
|
166475
|
166476
|
166535
|
166678
|
166679
|
166680
|
166684
|
166685
|
166686
|
166689
|
166693
|
166694
|
166695
|
166696
|
166763
|
166764
|
166765
|
166766
|
168190
|
168191
|
168192
|
168193
|
168194