From 9c49131279359a909dce8cb27aef94506d25e234 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Marques Date: Sat, 14 Nov 2009 19:43:03 +0000 Subject: [PATCH] Bug 3754: Follow-up patch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch is a follow-up patch for the one submitted by Nahuel Angelinetti for Bug 3754 (for 3.0.x). The bug is mentioned here: Bug 3754 - Language detection doesn't take really care of syspref http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3754 Nahuel's patch is here: http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=commitdiff;h=df25509e8c500c0e91b9f2343ebca1c7c98238cf I had a problem which was being uncapable of changing from "Português" (Portuguese) to "English" and vice-versa. The problem was solved after applying Nahuel's changes followed by this patch of mine. This patch is for 3.0.x (because it follows up on Nahuel's patch that was also for 3.0x). I'll let one that can test these two patches (Nahuel's and mine) for the "master" branch to test them and submit it for that branch. --- C4/Output.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Output.pm b/C4/Output.pm index 30b61d3745..19e946eba5 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -139,6 +139,7 @@ sub themelanguage { my $http_accept_language = $ENV{ HTTP_ACCEPT_LANGUAGE }; # But, if there's a cookie set, obey it $lang = $query->cookie('KohaOpacLanguage') if $query->cookie('KohaOpacLanguage'); + # Fall back to English my @languages; if ($interface eq 'intranet') { @@ -146,9 +147,23 @@ sub themelanguage { } else { @languages = split ",", C4::Context->preference("opaclanguages"); } - $lang = accept_language( $http_accept_language, + + # Ricardo Dias Marques + # 14-Nov-2009 + # - If we have a language set in the Cookie, we'll accept it if it exists in the list of Translated Languages + # - If we don't have a language set in the Cookie, we'll try to use the one set in the browser (available + # in $http_accept_language) if it also exists in the list of Translated Languages + if ($lang ne "") + { + $lang = accept_language( $lang, + getTranslatedLanguages($interface,'prog') ); + } + else + { + $lang = accept_language( $http_accept_language, getTranslatedLanguages($interface,'prog') ) if $http_accept_language; + } if (grep(/^$lang$/, @languages)){ @languages=($lang,@languages); -- 2.39.5