--- loncom/localize/lonlocal.pm 2003/09/16 15:23:43 1.1 +++ loncom/localize/lonlocal.pm 2003/09/17 01:45:14 1.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Localization routines # -# $Id: lonlocal.pm,v 1.1 2003/09/16 15:23:43 www Exp $ +# $Id: lonlocal.pm,v 1.4 2003/09/17 01:45:14 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,12 +32,15 @@ package Apache::lonlocal; use strict; use Apache::localize; +use Apache::File; require Exporter; our @ISA = qw (Exporter); our @EXPORT = qw(mt); +my $reroute; + # ========================================================= The language handle use vars qw($lh); @@ -45,13 +48,55 @@ use vars qw($lh); # ===================================================== The "MakeText" function sub mt (@) { - return $lh->maketext(@_); + unless ($ENV{'environment.translator'}) { + return $lh->maketext(@_); + } else { + my $trans=$lh->maketext(@_); + my $link='[['.$trans.']]'; + 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) sub get_language_handle { - $lh=Apache::localize->get_handle(); + $lh=Apache::localize->get_handle(&Apache::loncommon::preferred_languages); } 1;