Bugzilla – Attachment 126345 Details for
Bug 29245
Fix the parameters of getTranslatedLanguages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29245: Fix parameters of getTranslatedLanguages
Bug-29245-Fix-parameters-of-getTranslatedLanguages.patch (text/plain), 3.12 KB, created by
Marcel de Rooy
on 2021-10-15 14:42:23 UTC
(
hide
)
Description:
Bug 29245: Fix parameters of getTranslatedLanguages
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-10-15 14:42:23 UTC
Size:
3.12 KB
patch
obsolete
>From 90b9046dc503e3f2ffcbbfec94781585eb10a706 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 15 Oct 2021 08:02:11 +0000 >Subject: [PATCH] Bug 29245: Fix parameters of getTranslatedLanguages >Content-Type: text/plain; charset=utf-8 > >Removed which parameter. Unused. >Added fallbacks for interface and theme. >Adjusted POD. > >No test plan. If qa tools doesnt complain, you are fine. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Languages.pm | 33 +++++++++++++++++++-------------- > 1 file changed, 19 insertions(+), 14 deletions(-) > >diff --git a/C4/Languages.pm b/C4/Languages.pm >index c05c31bf9e..2840a5522f 100644 >--- a/C4/Languages.pm >+++ b/C4/Languages.pm >@@ -97,29 +97,34 @@ sub getFrameworkLanguages { > > =head2 getTranslatedLanguages > >-Returns a reference to an array of hashes: >+ my $languages = getTranslatedLanguages( 'opac', 'bootstrap' ); > >- my $languages = getTranslatedLanguages(); >- print "Available translated languages:\n"; >- for my $language(@$trlanguages) { >- print "$language->{language_code}\n"; # language code in iso 639-2 >- print "$language->{language_name}\n"; # language name in native script >- print "$language->{language_locale_name}\n"; # language name in current locale >- } >+ Parameter interface falls back to opac. >+ Parameter theme falls back to pref opacthemes or template (stafftheme). >+ >+ Returns a reference to an array of hashes. >+ >+ Key language_code refers to ISO 639-2. >+ Key language_name is name in native script. >+ Key language_locale_name is name in current locale. > > =cut > > sub getTranslatedLanguages { >- my ($interface, $theme, $current_language, $which) = @_; >+ my ( $interface, $theme, $current_language ) = @_; >+ $interface ||= 'opac'; >+ $theme ||= C4::Context->preference( >+ $interface eq 'opac' ? 'opacthemes' : 'template' >+ ); >+ > my @languages; >- my @enabled_languages = >- ( $interface && $interface eq 'intranet' ) >+ my @enabled_languages = $interface eq 'intranet' > ? split ",", C4::Context->preference('language') > : split ",", C4::Context->preference('OPACLanguages'); > > my $cache = Koha::Caches->get_instance; > my $cache_key = "languages_${interface}_${theme}"; >- if ($interface && $interface eq 'opac' ) { >+ if( $interface eq 'opac' ) { > my $htdocs = C4::Context->config('opachtdocs'); > my $cached = $cache->get_from_cache($cache_key); > if ( $cached ) { >@@ -129,7 +134,7 @@ sub getTranslatedLanguages { > $cache->set_in_cache($cache_key, \@languages ); > } > } >- elsif ($interface && $interface eq 'intranet' ) { >+ elsif( $interface eq 'intranet' ) { > my $htdocs = C4::Context->config('intrahtdocs'); > my $cached = $cache->get_from_cache($cache_key); > if ( $cached ) { >@@ -150,7 +155,7 @@ sub getTranslatedLanguages { > $seen{$_}++ for @languages; > @languages = keys %seen; > } >- return _build_languages_arrayref(\@languages,$current_language,\@enabled_languages); >+ return _build_languages_arrayref( \@languages, $current_language, \@enabled_languages ); > } > > =head2 getAllLanguages >-- >2.20.1
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 29245
:
126312
|
126313
|
126314
|
126315
|
126322
| 126345 |
126346
|
126347
|
126348