internationalization/localization, RT12515
[freeside.git] / FS / FS / Maketext.pm
1 package FS::Maketext;
2
3 use base qw( Exporter );
4 use FS::CurrentUser;
5 use FS::Conf;
6 use FS::L10N;
7 use HTML::Entities qw( encode_entities );
8
9 our @EXPORT_OK = qw( mt emt );
10
11 our $lh;
12
13 sub mt {
14   $lh ||= lh();
15   $lh->maketext(@_);
16 }
17
18 # HTML-escaped version of mt()
19 sub emt {
20     encode_entities(mt(@_));
21 }
22
23 sub lh {
24   my $locale =  $FS::CurrentUser::CurrentUser->option('locale')
25              || FS::Conf->new->config('locale')
26              || 'en_US';
27   $locale =~ s/_/-/g;
28   FS::L10N->get_handle($locale) || die "Unknown locale $locale";
29 }
30
31 # XXX pod me
32
33 1;