From c212b9328edd69a8e8f5082674a9f29741d159ee Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Thu, 3 Apr 2014 22:37:09 -0300 Subject: [PATCH] Bug 5052: make it possible to pick a language if all choices are sublanguage This was tricky to catch. In current implementation, Bug 6755 introduced in C4/Templates.pm as condition to send the array of hashrefs of languages that (@$languages_loop<2), but with one language group that condition is false, there is only one element in that array. This patch changes that condition to have more than one language selected, grouped or not. Also send $bidi value always, that was only sent if there is more than one group language. To test: 1. Translate to en-GB and en-NZ, or simply do mkdirs on intranet-tmpl/prog and opac-tmpl/bootstrap 2. Go to Administration > System preferences > I18N enable those languages on staff/opac 3. Check that language chooser is nowhere to be found 4. Apply the patch 5. Reload staff/opac, now you can see language chooser NOTE: I made little changes on staff, but can't replicate bootstrap colors for selected/unselected language. Someone need to touch css files to make it happen. But that is current behavior. Signed-off-by: Owen Leonard Signed-off-by: Jonathan Druart Good catch! Signed-off-by: Galen Charlton --- C4/Templates.pm | 11 +++++++---- .../prog/en/includes/intranet-bottom.inc | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index 2d2304f9d6..0b498626da 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -253,10 +253,13 @@ sub gettemplate { # lang => $lang # ); - # Bidirectionality + # Bidirectionality, must be sent even if is the only language my $current_lang = regex_lang_subtags($lang); my $bidi; $bidi = get_bidi($current_lang->{script}) if $current_lang->{script}; + $template->param( + bidi => $bidi, + ); # Languages my $languages_loop = getTranslatedLanguages($interface,$theme,$lang); my $num_languages_enabled = 0; @@ -265,11 +268,11 @@ sub gettemplate { $num_languages_enabled++ if $sublang->{enabled}; } } + my $one_language_enabled = ($num_languages_enabled <= 1) ? 1 : 0; # deal with zero enabled langs as well $template->param( languages_loop => $languages_loop, - bidi => $bidi, - one_language_enabled => ($num_languages_enabled <= 1) ? 1 : 0, # deal with zero enabled langs as well - ) unless @$languages_loop<2; + one_language_enabled => $one_language_enabled, + ) unless $one_language_enabled; return $template; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc index ed1298c478..442a7bba42 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -9,7 +9,7 @@ [% IF ( languages_loo.group_enabled ) %] [% IF ( languages_loo.plural ) %] -