version 1.3, 2003/09/16 22:40:25
|
version 1.9, 2003/09/20 17:44:22
|
Line 39 require Exporter;
|
Line 39 require Exporter;
|
our @ISA = qw (Exporter); |
our @ISA = qw (Exporter); |
our @EXPORT = qw(mt); |
our @EXPORT = qw(mt); |
|
|
|
my $reroute; |
|
|
# ========================================================= The language handle |
# ========================================================= The language handle |
|
|
use vars qw($lh); |
use vars qw($lh); |
Line 49 sub mt (@) {
|
Line 51 sub mt (@) {
|
unless ($ENV{'environment.translator'}) { |
unless ($ENV{'environment.translator'}) { |
return $lh->maketext(@_); |
return $lh->maketext(@_); |
} else { |
} else { |
return '<a target="trans" href="/cgi-bin/translator.pl?arg1='. |
my $trans=$lh->maketext(@_); |
|
my $link='<a target="trans" href="/cgi-bin/translator.pl?arg1='. |
&Apache::lonnet::escape($_[0]).'&arg2='. |
&Apache::lonnet::escape($_[0]).'&arg2='. |
&Apache::lonnet::escape($_[1]).'&arg3='. |
&Apache::lonnet::escape($_[1]).'&arg3='. |
&Apache::lonnet::escape($_[2]).'&lang='. |
&Apache::lonnet::escape($_[2]).'&lang='. |
$ENV{'environment.translator'}. |
$ENV{'environment.translator'}. |
'">'.$lh->maketext(@_).'</a>'; |
'">[['.$trans.']]</a>'; |
|
if ($ENV{'transreroute'}) { |
|
$reroute.=$link; |
|
return $trans; |
|
} else { |
|
return $link; |
|
} |
|
} |
|
} |
|
|
|
# ============================================================== What language? |
|
|
|
sub current_language { |
|
return $lh->language_tag(); |
|
} |
|
|
|
# ============================================================== What encoding? |
|
|
|
sub current_encoding { |
|
my $enc=$lh->maketext('char_encoding'); |
|
return ($enc eq 'char_encoding'?'':$enc); |
|
} |
|
|
|
# ============================================================== Translate hash |
|
|
|
sub texthash { |
|
my %hash=@_; |
|
foreach (keys %hash) { |
|
$hash{$_}=&mt($hash{$_}); |
|
} |
|
return %hash; |
|
} |
|
# ======================================================== Re-route translation |
|
|
|
sub clearreroutetrans { |
|
&reroutetrans(); |
|
$reroute=''; |
|
} |
|
|
|
# ======================================================== Re-route translation |
|
|
|
sub reroutetrans { |
|
$ENV{'transreroute'}=1; |
|
} |
|
|
|
# ==================================================== End re-route translation |
|
sub endreroutetrans { |
|
$ENV{'transreroute'}=0; |
|
if ($ENV{'environment.translator'}) { |
|
return $reroute; |
|
} else { |
|
return ''; |
} |
} |
} |
} |
|
|
# ========= 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; |
$lh=Apache::localize->get_handle(&Apache::loncommon::preferred_languages); |
$lh=Apache::localize->get_handle(&Apache::loncommon::preferred_languages); |
|
$r->content_languages(["¤t_language()"]); |
|
my $enc=¤t_encoding(); |
|
if ($enc) { |
|
|
|
} |
} |
} |
|
|
1; |
1; |