From be40a9fa3750374b32f2aa31e8807433c05d7817 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 May 2011 00:30:43 +0000 Subject: [PATCH] i18n, RT#12515 --- FS/FS/Maketext.pm | 27 +++++++++++++++++++++++++++ FS/FS/Mason.pm | 7 +------ FS/FS/Mason/Request.pm | 2 +- FS/MANIFEST | 3 +++ FS/t/L10N.t | 5 +++++ FS/t/Maketext.t | 5 +++++ httemplate/autohandler | 8 ++------ 7 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 FS/FS/Maketext.pm create mode 100644 FS/t/L10N.t create mode 100644 FS/t/Maketext.t diff --git a/FS/FS/Maketext.pm b/FS/FS/Maketext.pm new file mode 100644 index 000000000..319fb1d37 --- /dev/null +++ b/FS/FS/Maketext.pm @@ -0,0 +1,27 @@ +package FS::Maketext; + +use base qw( Exporter ); +use FS::CurrentUser; +use FS::Conf; +use FS::L10N; + +our @EXPORT_OK = qw( mt ); + +our $lh; + +sub mt { + $lh ||= lh(); + $lh->maketext(@_); +} + +sub lh { + my $locale = $FS::CurrentUser::CurrentUser->option('locale') + || FS::Conf->new->config('locale') + || 'en_US'; + $locale =~ s/_/-/g; + FS::L10N->get_handle($locale) || die "Unknown locale $locale"; +} + +# XXX pod me + +1; diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 07e650a41..6e3d7c9a0 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -140,7 +140,7 @@ if ( -e $addl_handler_use_file ) { use FS::NetworkMonitoringSystem; use FS::Tron qw( tron_lint ); use FS::Locales; - use FS::L10N; + use FS::Maketext qw( mt ); use FS::agent; use FS::agent_type; @@ -410,11 +410,6 @@ if ( -e $addl_handler_use_file ) { $m->comp('/elements/errorpage-popup.html', @_); } - sub mt { - use vars qw($lh); - $lh->maketext(@_); - } - sub redirect { my( $location ) = @_; use vars qw($m); diff --git a/FS/FS/Mason/Request.pm b/FS/FS/Mason/Request.pm index bf704bda7..d8fd77a66 100644 --- a/FS/FS/Mason/Request.pm +++ b/FS/FS/Mason/Request.pm @@ -51,7 +51,7 @@ sub freeside_setup { } else { package HTML::Mason::Commands; - use vars qw( $cgi $p $fsurl $lh ); + use vars qw( $cgi $p $fsurl ); # $lh ); #not using /mt use Encode; use FS::UID qw( cgisuidsetup ); use FS::CGI qw( popurl rooturl ); diff --git a/FS/MANIFEST b/FS/MANIFEST index 28518017e..3b80da8fc 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -597,3 +597,6 @@ t/rate_center.t FS/Locales.pm t/Locales.t FS/L10N.pm +t/L10N.t +FS/Maketext.pm +t/Maketext.t diff --git a/FS/t/L10N.t b/FS/t/L10N.t new file mode 100644 index 000000000..d8619cef6 --- /dev/null +++ b/FS/t/L10N.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::L10N; +$loaded=1; +print "ok 1\n"; diff --git a/FS/t/Maketext.t b/FS/t/Maketext.t new file mode 100644 index 000000000..a4241f1f0 --- /dev/null +++ b/FS/t/Maketext.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::Maketext; +$loaded=1; +print "ok 1\n"; diff --git a/httemplate/autohandler b/httemplate/autohandler index c676d3d2d..c326e3e18 100644 --- a/httemplate/autohandler +++ b/httemplate/autohandler @@ -1,13 +1,9 @@ % $m->call_next; <%init> - dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile'); + $FS::Maketext::lh = ''; - my $locale = $FS::CurrentUser::CurrentUser->option('locale') - || FS::Conf->new->config('locale') - || 'en_US'; - $locale =~ s/_/-/g; - $lh = FS::L10N->get_handle($locale) || die "Unknown locale $locale"; + dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile'); <%filter> -- 2.11.0