[Koha-patches] [PATCH] Bug 3754: Follow-up patch

Ricardo Dias Marques koha at ricmarques.net
Sat Nov 14 20:43:03 CET 2009


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 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/C4/Output.pm b/C4/Output.pm
index 30b61d3..19e946e 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, at languages);
-- 
1.5.6.5




More information about the Koha-patches mailing list