Skip to content

Commit

Permalink
Item12285: More robust fix for MAKETEXT
Browse files Browse the repository at this point in the history
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
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Dec 17, 2012
1 parent 81e045f commit 5ce96e3
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions core/lib/Foswiki/Macros/MAKETEXT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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 );

Expand All @@ -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<span class='foswikiAccessKey'>$2</span>#g;
Expand Down

0 comments on commit 5ce96e3

Please sign in to comment.