From 18db2b641feada9d073de97a918b9a84b5a9729d Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 27 Jul 2011 23:56:55 +0000 Subject: [PATCH] fix i18n of javascript re-print/email confirmations, RT#12515 --- FS/FS/Maketext.pm | 12 +++++++++++- FS/FS/Mason.pm | 3 ++- httemplate/search/cust_bill.html | 10 +++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/FS/FS/Maketext.pm b/FS/FS/Maketext.pm index 965c9990c..ccfc1204b 100644 --- a/FS/FS/Maketext.pm +++ b/FS/FS/Maketext.pm @@ -6,7 +6,7 @@ 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; @@ -20,6 +20,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') diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 934004e4a..3691975ee 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::Maketext qw( mt emt ); + use FS::Maketext qw( mt emt js_mt ); use FS::agent; use FS::agent_type; @@ -526,6 +526,7 @@ sub mason_interps { my $html_defang = new HTML::Defang (%defang_opts); + #false laziness w/ FS::Maketext js_mt my $js_string_sub = sub { #${$_[0]} =~ s/(['\\\n])/'\\'.($1 eq "\n" ? 'n' : $1)/ge; ${$_[0]} =~ s/(['\\])/\\$1/g; diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 627703691..4117112f5 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -205,31 +205,31 @@ my $html_init = join("\n", map { '