From 239cf0b82af1183b5090c706feb1fff8240e1344 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 15 Oct 2021 12:05:45 +0000 Subject: [PATCH] Bug 29245: Fix calls of getTranslatedLanguages Content-Type: text/plain; charset=utf-8 admin/preferences: $current_languages was ignored already. admin/systempreferences: see preferences; note that bug 29251 should fix already broken behavior. tools/letter: combining opac and prog was wrong, but caught by the else branch in get_opac_languages. members/memberentry: same as letter. tools/additional-contents: actually no change, but better to write in full. opac/opac-messaging.pl: same as letter, caught by else. admin/itemtypes: should be same as admin/localization. Test plan: Have a few opac and staff languages. Check on some of the above forms the languages display. Keep in mind that some staff scripts select translated languages for the OPAC. Signed-off-by: Marcel de Rooy --- admin/itemtypes.pl | 2 +- admin/preferences.pl | 4 +--- admin/systempreferences.pl | 27 ++++----------------------- members/memberentry.pl | 2 +- opac/opac-messaging.pl | 2 +- tools/additional-contents.pl | 2 +- tools/letter.pl | 3 +-- 7 files changed, 10 insertions(+), 32 deletions(-) diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 8652c3de9f..198d014617 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -60,7 +60,7 @@ if ( $op eq 'add_form' ) { my $parent_types = Koha::ItemTypes->search({parent_type=>undef,itemtype => {'!='=>$itemtype_code}}); my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) ); my $searchcategory = GetAuthorisedValues("ITEMTYPECAT"); - my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') ); + my $translated_languages = C4::Languages::getTranslatedLanguages( 'intranet', C4::Context->preference('template') ); # same as localization.pl $template->param( itemtype => $itemtype, parent_type => $parent_type, diff --git a/admin/preferences.pl b/admin/preferences.pl index 9e697a6a03..b4ec57bba5 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -72,8 +72,6 @@ sub _get_chunk { } elsif ( $options{'class'} && $options{'class'} eq 'date' ) { $chunk->{'dateinput'} = 1; } elsif ( $options{'type'} && ( $options{'type'} eq 'opac-languages' || $options{'type'} eq 'staff-languages' ) ) { - my $current_languages = { map { +$_, 1 } split( /\s*,\s*/, $value ) }; - my $theme; my $interface; if ( $options{'type'} eq 'opac-languages' ) { @@ -85,7 +83,7 @@ sub _get_chunk { $interface = 'intranet'; $theme = C4::Context->preference('template'); } - $chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, undef, $current_languages ); + $chunk->{'languages'} = getTranslatedLanguages( $interface, $theme ); $chunk->{'type'} = 'languages'; } elsif ( $options{ 'choices' } ) { my $add_blank; diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 1eb54552b1..22a3572880 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -166,30 +166,11 @@ sub GetPrefParams { $counter++; } } elsif ( $data->{'type'} eq 'Languages' ) { - my $currently_selected_languages; - foreach my $language ( split /\s+/, $data->{'value'} ) { - $currently_selected_languages->{$language} = 1; - } - - # current language - my $lang = $params->{'lang'}; - my $theme; - my $interface; - if ( $data->{'variable'} =~ /opac/ ) { - - # this is the OPAC - $interface = 'opac'; - $theme = C4::Context->preference('opacthemes'); - } else { - - # this is the staff interface - $interface = 'intranet'; - $theme = C4::Context->preference('template'); - } - my $languages_loop = getTranslatedLanguages( $interface, $theme, $lang, $currently_selected_languages ); - - $params->{'languages_loop'} = $languages_loop; + my $interface = $data->{'variable'} =~ /opac/i ? 'opac' : 'intranet'; + my $theme = C4::Context->preference( $interface eq 'opac' ? 'opacthemes' : 'template' ); + $params->{'languages_loop'} = getTranslatedLanguages( $interface, $theme ); $params->{'type_langselector'} = 1; + #FIXME Bug 29251: Make sure that current selection is checked (within borders of enabled) } else { $params->{'type_free'} = 1; $params->{'fieldlength'} = ( defined( $data->{'options'} ) and $data->{'options'} and $data->{'options'} > 0 ) ? $data->{'options'} : 30; diff --git a/members/memberentry.pl b/members/memberentry.pl index d85e55e54a..130978e60a 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -864,7 +864,7 @@ if ( defined $min ) { } if ( C4::Context->preference('TranslateNotices') ) { - my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', C4::Context->preference('template') ); + my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', 'bootstrap' ); $template->param( languages => $translated_languages ); } diff --git a/opac/opac-messaging.pl b/opac/opac-messaging.pl index 40643830c6..5f96eeb4f6 100755 --- a/opac/opac-messaging.pl +++ b/opac/opac-messaging.pl @@ -91,7 +91,7 @@ $template->param( ); if ( C4::Context->preference('TranslateNotices') ) { - my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', C4::Context->preference('template') ); + my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', 'bootstrap' ); $template->param( languages => $translated_languages, patron_lang => $patron->lang, diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl index 2e87f23d68..38537814b1 100755 --- a/tools/additional-contents.pl +++ b/tools/additional-contents.pl @@ -225,7 +225,7 @@ if ( $op eq 'list' ) { $template->param( additional_contents => $additional_contents ); } -my $translated_languages = C4::Languages::getTranslatedLanguages; +my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', 'bootstrap' ); my @languages; for my $language (@$translated_languages) { for my $sublanguage ( @{ $language->{sublanguages_loop} } ) { diff --git a/tools/letter.pl b/tools/letter.pl index 68b9eed449..df5d38d610 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -160,8 +160,7 @@ sub add_form { if ( C4::Context->preference('TranslateNotices') ) { my $translated_languages = - C4::Languages::getTranslatedLanguages( 'opac', - C4::Context->preference('template') ); + C4::Languages::getTranslatedLanguages( 'opac', 'bootstrap' ); for my $language (@$translated_languages) { for my $sublanguage( @{ $language->{sublanguages_loop} } ) { if ( $language->{plural} ) { -- 2.20.1