[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm /localize lonlocal.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 22 Dec 2003 23:34:49 -0000


www		Mon Dec 22 18:34:49 2003 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
    /loncom/localize	lonlocal.pm 
  Log:
  Bug #2471: our localization scheme only worked because get_language_handle
  was usually called when $ENV{'HTTP_ACCEPT_LANGUAGE'} was not yet set. That
  was not the case when an internal redirect had happened.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.161 loncom/interface/loncommon.pm:1.162
--- loncom/interface/loncommon.pm:1.161	Mon Dec 22 17:39:07 2003
+++ loncom/interface/loncommon.pm	Mon Dec 22 18:34:49 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.161 2003/12/22 22:39:07 www Exp $
+# $Id: loncommon.pm,v 1.162 2003/12/22 23:34:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1617,6 +1617,10 @@
     if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) {
 	@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,
 	         $ENV{'course.'.$ENV{'request.course.id'}.'.languages'}));
+    }
+    my $browser=(split(/\;/,$ENV{'HTTP_ACCEPT_LANGUAGE'}))[0];
+    if ($browser) {
+	@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser));
     }
     if ($Apache::lonnet::domain_lang_def{$ENV{'user.domain'}}) {
 	@languages=(@languages,
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.28 loncom/localize/lonlocal.pm:1.29
--- loncom/localize/lonlocal.pm:1.28	Mon Dec 22 17:39:07 2003
+++ loncom/localize/lonlocal.pm	Mon Dec 22 18:34:49 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Localization routines
 #
-# $Id: lonlocal.pm,v 1.28 2003/12/22 22:39:07 www Exp $
+# $Id: lonlocal.pm,v 1.29 2003/12/22 23:34:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -236,14 +236,12 @@
 
 sub get_language_handle {
     my $r=shift;
-    my $languages=&Apache::loncommon::preferred_languages;
-    unless ($languages) {
-	my $headers=$r->headers_in;
-	$ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'};
-    } else {
-	$ENV{'HTTP_ACCEPT_LANGUAGE'}='';
-    }
-    $lh=Apache::localize->get_handle($languages);
+    my $headers=$r->headers_in;
+    $ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'};
+    my @languages=&Apache::loncommon::preferred_languages;
+    $ENV{'HTTP_ACCEPT_LANGUAGE'}='';
+    &Apache::lonnet::logthis($r->uri.' '.join(' ',@languages));
+    $lh=Apache::localize->get_handle(@languages);
     if (&Apache::lonnet::mod_perl_version == 1) {
 	$r->content_languages([&current_language()]);
     }