From 5ce96e3d0bf0659243018d6e00c6f3b634acde93 Mon Sep 17 00:00:00 2001 From: GeorgeClark Date: Mon, 17 Dec 2012 19:15:14 +0000 Subject: [PATCH] Item12285: More robust fix for MAKETEXT Instead of trying to double up the escapes, completely remove them from the string and then restore after translation. This is a TEST fix. git-svn-id: http://svn.foswiki.org/trunk@16232 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- core/lib/Foswiki/Macros/MAKETEXT.pm | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/core/lib/Foswiki/Macros/MAKETEXT.pm b/core/lib/Foswiki/Macros/MAKETEXT.pm index 428a4aedd7..808b95421b 100644 --- a/core/lib/Foswiki/Macros/MAKETEXT.pm +++ b/core/lib/Foswiki/Macros/MAKETEXT.pm @@ -4,19 +4,11 @@ package Foswiki; use strict; use warnings; -use Locale::Maketext; -my $escape = - ( $Foswiki::cfg{UserInterfaceInternationalisation} - && $Locale::Maketext::VERSION - && $Locale::Maketext::VERSION < 1.23 ); +my $TT1 = chr(1); sub MAKETEXT { my ( $this, $params ) = @_; - my $max; - my $min; - my $param_error; - my $str = $params->{_DEFAULT} || $params->{string} || ""; return "" unless $str; @@ -28,9 +20,9 @@ sub MAKETEXT { $str =~ s/~~\[/~[/g; $str =~ s/~~\]/~]/g; - $max = 0; - $min = 1; - $param_error = 0; + my $max = 0; + my $min = 1; + my $param_error = 0; # unescape parameters and calculate highest parameter number: $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge; @@ -41,8 +33,8 @@ s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_erro # get the args to be interpolated. my $argsStr = $params->{args} || ""; - # Escape any escapes. - $str =~ s#\\#\\\\#g if ($escape); # escape any escapes + # Remove any escapes. + $str =~ s#\\#<$TT1>#g; my @args = split( /\s*,\s*/, $argsStr ); @@ -54,6 +46,9 @@ s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_erro # do the magic: my $result = $this->i18n->maketext( $str, @args ); + # Restore the escapes. + $result =~ s#<$TT1>#\\#g; + # replace accesskeys: $result =~ s#(^|[^&])&([a-zA-Z])#$1$2#g;