From 2e1e55fb952436384a1f18eb512d9bd9e1072c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Wed, 17 Oct 2012 17:14:17 +0200 Subject: [PATCH] Bug 8942 Fix translation of JS strings containing simple/double quote With this patch, translated strings containing simple or double quotes are transformed to their HTML entities counterpart. This prevent breaking JavaScript strings. For example: Today, translated in French is Aujourd'hui. And so this JS line: var m = _('Today'); become in French: var m = _('Aujourd'hui'); It breaks the whole JS code. With this patch: var m = _('Ajourd'hui'); Same issue with ", and JS strings like "foo". --- misc/translator/tmpl_process3.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index 89c993f..e2420b5 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -117,8 +117,10 @@ sub text_replace (**) { for my $t (@{$s->js_data}) { # FIXME for this whole block if ($t->[0]) { - printf $output "%s%s%s", $t->[2], find_translation $t->[3], - $t->[2]; + my $translation = find_translation $t->[3]; + $translation =~ s/'/'/g; + $translation =~ s/"/"/g; + printf $output "%s%s%s", $t->[2], $translation, $t->[2]; } else { print $output $t->[1]; } -- 1.7.12.3