Permalink
Browse files

Fix overzealous escaping for localization.

Per Locale::Maketext docs, commas only need to be escaped when inside
bracket notation.

[#245 state:resolved]
  • Loading branch information...
1 parent a9e4e61 commit a5ce90c79116d7d18b6df2022e1f3c629f6d9c98 @gregheo gregheo committed with theory May 9, 2011
Showing with 13 additions and 1 deletion.
  1. +1 −1 comp/widgets/wrappers/header.mc
  2. +12 −0 t/Bric/Util/Language/Test.pm
View
2 comp/widgets/wrappers/header.mc
@@ -37,7 +37,7 @@ for (@context){
s/\s+$//g;
if (/^(\"?)(.+?)(\"?)$/) {
my ($startquote, $text, $endquote) = ($1, $2, $3);
- $text =~ s/([\[\],~])/~$1/g;
+ $text =~ s/([\[\]~])/~$1/g;
my $underscores = ($text =~ s/^(_+)//) ? $1 : '';
$_ = qq{$startquote<span class="110n">$underscores}
. $lang->maketext($text) . "</span>$endquote";
View
12 t/Bric/Util/Language/Test.pm
@@ -19,5 +19,17 @@ sub _test_load : Test(17) {
closedir LANGS;
}
+##############################################################################
+# Test escaped special characters
+##############################################################################
+sub test_localize : Test(3) {
+ use_ok('Bric::Util::Language');
+ ok(my $lang = Bric::Util::Language->get_handle("de_de"),
+ 'Get German translation');
+ is($lang->maketext('Me, ~~myself~~, and ~[I~] ~,'),
+ 'Me, ~myself~, and [I] ~,',
+ "Special characters are unescaped properly");
+}
+
1;
__END__

0 comments on commit a5ce90c

Please sign in to comment.