fix i18n of javascript re-print/email confirmations, RT#12515
authorivan <ivan>
Wed, 27 Jul 2011 23:56:55 +0000 (23:56 +0000)
committerivan <ivan>
Wed, 27 Jul 2011 23:56:55 +0000 (23:56 +0000)
FS/FS/Maketext.pm
FS/FS/Mason.pm
httemplate/search/cust_bill.html

index 965c999..ccfc120 100644 (file)
@@ -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')
index 934004e..3691975 100644 (file)
@@ -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;
index 6277036..4117112 100755 (executable)
@@ -205,31 +205,31 @@ my $html_init = join("\n", map {
 '<SCRIPT TYPE="text/javascript">
 
 function confirm_print_process() {
-  if ( ! confirm('.emt("Are you sure you want to reprint these invoices?").') ) {
+  if ( ! confirm('.js_mt("Are you sure you want to reprint these invoices?").') ) {
     return;
   }
   print_process();
 }
 function confirm_email_process() {
-  if ( ! confirm('.emt("Are you sure you want to re-email these invoices?").') ) {
+  if ( ! confirm('.js_mt("Are you sure you want to re-email these invoices?").') ) {
     return;
   }
   email_process();
 }
 function confirm_fax_process() {
-  if ( ! confirm('.emt("Are you sure you want to re-fax these invoices?").') ) {
+  if ( ! confirm('.js_mt("Are you sure you want to re-fax these invoices?").') ) {
     return;
   }
   fax_process();
 }
 function confirm_ftp_process() {
-  if ( ! confirm('.emt("Are you sure you want to re-FTP these invoices?").') ) {
+  if ( ! confirm('.js_mt("Are you sure you want to re-FTP these invoices?").') ) {
     return;
   }
   ftp_process();
 }
 function confirm_spool_process() {
-  if ( ! confirm('.emt("Are you sure you want to re-spool these invoices?").') ) {
+  if ( ! confirm('.js_mt("Are you sure you want to re-spool these invoices?").') ) {
     return;
   }
   spool_process();