Diff for /loncom/localize/lonlocal.pm between versions 1.26 and 1.34

version 1.26, 2003/11/07 23:22:22 version 1.34, 2005/06/22 05:04:51
Line 161  but for most purposes, we do not have to Line 161  but for most purposes, we do not have to
 package Apache::lonlocal;  package Apache::lonlocal;
   
 use strict;  use strict;
   use Apache::Constants qw(:common);
 use Apache::localize;  use Apache::localize;
 use Apache::File;  use Apache::File;
 use locale;  use locale;
Line 184  sub mt (@) { Line 185  sub mt (@) {
     if ($lh) {      if ($lh) {
  return $lh->maketext(@_);   return $lh->maketext(@_);
     } else {      } else {
  return @_;   if (wantarray) {
       return @_;
    } else {
       return $_[0];
    }
     }      }
 }  }
   
Line 201  sub current_language { Line 206  sub current_language {
 # ============================================================== What encoding?  # ============================================================== What encoding?
   
 sub current_encoding {  sub current_encoding {
       my $default='UTF-8';
       if ($Apache::lonnet::env{'browser.os'} eq 'win' && 
    $Apache::lonnet::env{'browser.type'} eq 'explorer') {
           $default='ISO-8859-1';
       }
     if ($lh) {      if ($lh) {
  my $enc=$lh->maketext('char_encoding');   my $enc=$lh->maketext('char_encoding');
  return ($enc eq 'char_encoding'?'':$enc);   return ($enc eq 'char_encoding'?$default:$enc);
     } else {      } else {
  return undef;   return $default;
     }      }
 }  }
   
Line 235  sub texthash { Line 245  sub texthash {
   
 sub get_language_handle {  sub get_language_handle {
     my $r=shift;      my $r=shift;
     $lh=Apache::localize->get_handle(&Apache::loncommon::preferred_languages);      if ($r) {
     if (&Apache::lonnet::mod_perl_version == 1) {   my $headers=$r->headers_in;
    $ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'};
       }
       my @languages=&Apache::loncommon::preferred_languages;
       $ENV{'HTTP_ACCEPT_LANGUAGE'}='';
       $lh=Apache::localize->get_handle(@languages);
       if ($r && &Apache::lonnet::mod_perl_version == 1) {
  $r->content_languages([&current_language()]);   $r->content_languages([&current_language()]);
     }      }
 ###    setlocale(LC_ALL,&current_locale);  ###    setlocale(LC_ALL,&current_locale);
Line 317  sub mtn (@) { Line 333  sub mtn (@) {
     }      }
 }  }
   
   # ---------------------------------------------------- Replace MT{...} in files
   
   sub transstatic {
       my $strptr=shift;
       $$strptr=~s/MT\{([^\}]*)\}/&mt($1)/gse;
   }
   
   # ----------------------------------------------- Handler Routine /adm/localize
   sub handler {
       my $r=shift;
       &Apache::lonlocal::get_language_handle($r);
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       return OK if $r->header_only;
   
       my $uri=$r->uri;
       $uri=~s/^\/adm\/localize//;
       my $fn=$Apache::lonnet::perlvar{'lonDocRoot'}.$uri;
   
       my $file=&Apache::lonnet::getfile($fn);
       &transstatic(\$file);
       $r->print($file);
       return OK;
   }
   
 1;  1;
   
 __END__  __END__

Removed from v.1.26  
changed lines
  Added in v.1.34


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>