X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMaketext.pm;h=c90e573037cd7fef36fa43848ff73f0622a9fba0;hb=80511cb4158b98db01deec317e5408675487bc6e;hp=965c9990cded7a9e786d2067fa4512be3a3e8fd1;hpb=5fdd19665fb7c0ad425a99d3dbf9ad7e27fbf44a;p=freeside.git diff --git a/FS/FS/Maketext.pm b/FS/FS/Maketext.pm index 965c9990c..c90e57303 100644 --- a/FS/FS/Maketext.pm +++ b/FS/FS/Maketext.pm @@ -6,11 +6,12 @@ use FS::Conf; use FS::L10N; use HTML::Entities qw( encode_entities ); -our @EXPORT_OK = qw( mt emt ); +our @EXPORT_OK = qw( mt emt js_mt ); our $lh; sub mt { + return '' if $_[0] eq ''; $lh ||= lh(); $lh->maketext(@_); } @@ -20,6 +21,16 @@ sub emt { encode_entities(mt(@_)); } +# Javascript-escaped version of mt() +sub js_mt { + my $s = mt(@_); + #false laziness w/Mason.pm + $s =~ s/(['\\])/\\$1/g; + $s =~ s/\r/\\r/g; + $s =~ s/\n/\\n/g; + $s = "'$s'"; +} + sub lh { my $locale = $FS::CurrentUser::CurrentUser->option('locale') || FS::Conf->new->config('locale')