X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FMsgcat.pm;h=e1bde8b51123f6b14dcb8e414f5ee4956a9cc932;hp=2429805158fd4f432e33591d89ded6fc264c84dd;hb=f822e27a1e00594332ffa487a1c284234c5580a6;hpb=db303b2cb273b45e03467f36e076b7c1db3bc4a4 diff --git a/FS/FS/Msgcat.pm b/FS/FS/Msgcat.pm index 242980515..e1bde8b51 100644 --- a/FS/FS/Msgcat.pm +++ b/FS/FS/Msgcat.pm @@ -1,7 +1,7 @@ package FS::Msgcat; use strict; -use vars qw( @ISA @EXPORT_OK $conf $def_locale $debug ); +use vars qw( @ISA @EXPORT_OK $conf $def_locale $debug @translate_auto_insert ); use Exporter; use FS::UID; #use FS::Record qw( qsearchs ); # wtf? won't import... @@ -17,7 +17,8 @@ FS::UID->install_callback( sub { die $@ if $@; $conf = new FS::Conf; $def_locale = $conf->config('locale') || 'en_US'; - $debug = $conf->exists('show-msgcat-codes') + $debug = $conf->exists('show-msgcat-codes'); + @translate_auto_insert = $conf->config('translate-auto-insert'); }); =head1 NAME @@ -58,8 +59,10 @@ our %cache; sub _gettext { my $msgcode = shift; + return '' unless defined($msgcode) && length($msgcode) > 0; + my $locale = (@_ && shift) - || $FS::CurrentUser::CurrentUser->option('locale') + || $FS::CurrentUser::CurrentUser->locale || $def_locale; return $cache{$locale}->{$msgcode} if exists $cache{$locale}->{$msgcode}; @@ -75,7 +78,6 @@ sub _gettext { unless $locale eq 'en_US'; $cache{$locale}->{$msgcode} = $msgcode; - my @translate_auto_insert = $conf->config('translate-auto-insert'); if ( $locale ne 'en_US' && grep { $_ eq $locale } @translate_auto_insert ) { # :( @@ -86,6 +88,7 @@ sub _gettext { warn "WARNING: auto-inserting message for msgcode $msgcode in locale $locale"; $newmsgcat->insert; } + return $msgcode; } }