X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/452227b24a04660f5236d2d399f4839d0fbdc030..5367525b274785435844298fcf299cdd4d1ac2bd:/SL/Locale.pm diff --git a/SL/Locale.pm b/SL/Locale.pm index 0d2a89517..05f55ce46 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -37,6 +37,7 @@ package Locale; use Text::Iconv; +use List::Util qw(first); use SL::LXDebug; use SL::Common; @@ -208,27 +209,30 @@ sub findsub { $main::lxdebug->enter_sub(); my ($self, $text) = @_; - my $text_rev = $self->{iconv_reverse}->convert($text); + my $text_rev = lc $self->{iconv_reverse}->convert($text); - $self->{subs} ||= { }; + if (!$self->{texts_reverse}) { + $self->{texts_reverse} = { }; + while (my ($original, $translation) = each %{ $self->{texts} }) { + $original = lc $original; + $original =~ s/[^a-z0-9]/_/g; + $original =~ s/_+/_/g; - if (!$self->{subs}->{$text_rev}) { - $self->{texts_reverse} ||= { reverse %{ $self->{texts} } }; - my $sub_name = $self->{texts_reverse}->{$text_rev}; - $sub_name ||= $text_rev if $text_rev =~ m/^[a-z][a-z0-9_]+$/; + $translation = lc $translation; - $main::form->error("$text not defined in locale/$self->{countrycode}/all") if !$sub_name; + $self->{texts_reverse}->{$translation} ||= [ ]; + push @{ $self->{texts_reverse}->{$translation} }, $original; + } + } - $sub_name = lc $sub_name; - $sub_name =~ s/[^a-z0-9]/_/g; - $sub_name =~ s/_+/_/g; + my $sub_name = first { defined &{ "::$_" } } @{ $self->{texts_reverse}->{$text_rev} } if $self->{texts_reverse}->{$text_rev}; + $sub_name ||= $text_rev if ($text_rev =~ m/^[a-z][a-z0-9_]+$/) && defined &{ "::$text_rev" }; - $self->{subs}->{$text_rev} = $sub_name; - } + $main::form->error("$text not defined in locale/$self->{countrycode}/all") if !$sub_name; $main::lxdebug->leave_sub(); - return $self->{subs}->{$text_rev}; + return $sub_name; } sub date {