version 1.1, 2003/09/16 15:23:43
|
version 1.4, 2003/09/17 01:45:14
|
Line 32 package Apache::lonlocal;
|
Line 32 package Apache::lonlocal;
|
|
|
use strict; |
use strict; |
use Apache::localize; |
use Apache::localize; |
|
use Apache::File; |
|
|
require Exporter; |
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 45 use vars qw($lh);
|
Line 48 use vars qw($lh);
|
# ===================================================== The "MakeText" function |
# ===================================================== The "MakeText" function |
|
|
sub mt (@) { |
sub mt (@) { |
return $lh->maketext(@_); |
unless ($ENV{'environment.translator'}) { |
|
return $lh->maketext(@_); |
|
} else { |
|
my $trans=$lh->maketext(@_); |
|
my $link='<a target="trans" href="/cgi-bin/translator.pl?arg1='. |
|
&Apache::lonnet::escape($_[0]).'&arg2='. |
|
&Apache::lonnet::escape($_[1]).'&arg3='. |
|
&Apache::lonnet::escape($_[2]).'&lang='. |
|
$ENV{'environment.translator'}. |
|
'">[['.$trans.']]</a>'; |
|
if ($ENV{'transreroute'}) { |
|
$reroute.=$link; |
|
return $trans; |
|
} else { |
|
return $link; |
|
} |
|
} |
|
} |
|
|
|
# ============================================================== Translate hash |
|
|
|
sub texthash { |
|
my %hash=@_; |
|
foreach (keys %hash) { |
|
$hash{$_}=&mt($hash{$_}); |
|
} |
|
return %hash; |
|
} |
|
|
|
# ======================================================== Re-route translation |
|
|
|
sub reroutetrans { |
|
$ENV{'transreroute'}=1; |
|
$reroute=''; |
|
} |
|
# ==================================================== 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 { |
$lh=Apache::localize->get_handle(); |
$lh=Apache::localize->get_handle(&Apache::loncommon::preferred_languages); |
} |
} |
|
|
1; |
1; |