version 1.60.4.1, 2009/12/07 04:05:18
|
version 1.63, 2011/08/03 18:25:16
|
Line 242 sub current_language {
|
Line 242 sub current_language {
|
} |
} |
|
|
sub preferred_languages { |
sub preferred_languages { |
my $defdom = &Apache::lonnet::default_login_domain(); |
|
foreach my $domtype ($Apache::lonnet::env{'user.domain'},$Apache::lonnet::env{'request.role.domain'},$defdom) { |
|
next if ($domtype eq ''); |
|
if ($domtype eq 'gci') { |
|
return ('gci'); |
|
} elsif ($domtype eq 'gcitest') { |
|
return ('gct'); |
|
} else { |
|
return ('gci'); |
|
} |
|
} |
|
my @languages=(); |
my @languages=(); |
if (($Apache::lonnet::env{'request.role.adv'}) && ($Apache::lonnet::env{'form.languages'})) { |
if (($Apache::lonnet::env{'request.role.adv'}) && ($Apache::lonnet::env{'form.languages'})) { |
@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$Apache::lonnet::env{'form.languages'})); |
@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$Apache::lonnet::env{'form.languages'})); |
Line 273 sub preferred_languages {
|
Line 262 sub preferred_languages {
|
push(@languages,@browser); |
push(@languages,@browser); |
} |
} |
|
|
|
my $defdom = &Apache::lonnet::default_login_domain(); |
foreach my $domtype ($Apache::lonnet::env{'user.domain'},$Apache::lonnet::env{'request.role.domain'},$defdom) { |
foreach my $domtype ($Apache::lonnet::env{'user.domain'},$Apache::lonnet::env{'request.role.domain'},$defdom) { |
if ($domtype ne '') { |
if (($domtype ne '') && ($domtype ne 'public')) { |
my %domdefs = &Apache::lonnet::get_domain_defaults($domtype); |
my %domdefs = &Apache::lonnet::get_domain_defaults($domtype); |
if ($domdefs{'lang_def'} ne '') { |
if ($domdefs{'lang_def'} ne '') { |
push(@languages,$domdefs{'lang_def'}); |
push(@languages,$domdefs{'lang_def'}); |
Line 305 sub get_genlanguages {
|
Line 295 sub get_genlanguages {
|
|
|
sub current_encoding { |
sub current_encoding { |
my $default='UTF-8'; |
my $default='UTF-8'; |
# UTF-8 character encoding needed for the whole LON-CAPA system |
unless ($Apache::lonnet::env{'browser.unicode'}) { |
# (interface language and homework problem content) |
if ($Apache::lonnet::env{'browser.os'} eq 'win' && |
# See Bugzilla 5702 vs. 2189 and 4067 |
$Apache::lonnet::env{'browser.type'} eq 'explorer') { |
# if ($Apache::lonnet::env{'browser.os'} eq 'win' && |
$default='ISO-8859-1'; |
# $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'?$default:$enc); |
return ($enc eq 'char_encoding'?$default:$enc); |
Line 345 sub texthash {
|
Line 334 sub texthash {
|
# ========= Get a handle (do not invoke in vain, leave this to access handlers) |
# ========= Get a handle (do not invoke in vain, leave this to access handlers) |
|
|
sub get_language_handle { |
sub get_language_handle { |
my $r=shift; |
my ($r,$chosen) = @_; |
if ($r) { |
if ($r) { |
my $headers=$r->headers_in; |
my $headers=$r->headers_in; |
$ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'}; |
$ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'}; |
} |
} |
my @languages=&preferred_languages(); |
my @languages; |
|
if ($chosen ne '') { |
|
@languages=($chosen); |
|
} else { |
|
@languages=&preferred_languages(); |
|
} |
$ENV{'HTTP_ACCEPT_LANGUAGE'}=''; |
$ENV{'HTTP_ACCEPT_LANGUAGE'}=''; |
$lh=Apache::localize->get_handle(@languages); |
$lh=Apache::localize->get_handle(@languages); |
$current_language=¤t_language(); |
$current_language=¤t_language(); |
Line 388 sub gettimezone {
|
Line 382 sub gettimezone {
|
if ($uroledomdefs{'timezone_def'} ne '') { |
if ($uroledomdefs{'timezone_def'} ne '') { |
$timezone = $uroledomdefs{'timezone_def'}; |
$timezone = $uroledomdefs{'timezone_def'}; |
} |
} |
} elsif ($Apache::lonnet::env{'user.domain'} ne '') { |
} elsif (($Apache::lonnet::env{'user.domain'} ne '') && |
|
($Apache::lonnet::env{'user.domain'} ne 'public')) { |
my %udomdefaults = |
my %udomdefaults = |
&Apache::lonnet::get_domain_defaults($Apache::lonnet::env{'user.domain'}); |
&Apache::lonnet::get_domain_defaults($Apache::lonnet::env{'user.domain'}); |
if ($udomdefaults{'timezone_def'} ne '') { |
if ($udomdefaults{'timezone_def'} ne '') { |
Line 580 sub mt_escape {
|
Line 575 sub mt_escape {
|
$$str_ref =~s/([\[\]])/~$1/g; |
$$str_ref =~s/([\[\]])/~$1/g; |
} |
} |
|
|
|
=pod |
|
|
|
=item * choose_language |
|
|
|
choose_language prompts a user to enter a two letter language code via |
|
keyboard when running a script from the command line. Default is en. |
|
|
|
=cut |
|
|
|
sub choose_language { |
|
my %languages = ( |
|
ar => 'Arabic', |
|
de => 'German', |
|
en => 'English', |
|
es => 'Spanish', |
|
fa => 'Persian', |
|
fr => 'French', |
|
he => 'Hebrew', |
|
ja => 'Japanese', |
|
pt => 'Portuguese', |
|
ru => 'Russian', |
|
tr => 'Turkish', |
|
zh => 'Chinese (Simplified)' |
|
); |
|
my @posslangs = sort(keys(%languages)); |
|
my $langlist = join('|',@posslangs); |
|
my $lang = 'en'; |
|
print 'Language: English (en). Change? ['.$langlist.']? '; |
|
my $langchoice = <STDIN>; |
|
chomp($langchoice); |
|
$langchoice =~ s/(^\s+|\s+$)//g; |
|
$langchoice = lc($langchoice); |
|
if (defined($languages{$langchoice})) { |
|
$lang = $langchoice; |
|
} |
|
return $lang; |
|
} |
|
|
1; |
1; |
|
|
__END__ |
__END__ |