Bugzilla – Attachment 13151 Details for
Bug 8942
Translation process breaks javascript in calendar.inc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 8942 Fix translation of JS strings containing simple/double quote
SIGNED-OFF-Bug-8942-Fix-translation-of-JS-strings-.patch (text/plain), 1.69 KB, created by
Owen Leonard
on 2012-10-31 18:00:09 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 8942 Fix translation of JS strings containing simple/double quote
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2012-10-31 18:00:09 UTC
Size:
1.69 KB
patch
obsolete
>From 96c6cff1ee564d029c954edebc7964b6c1593c2a Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= <f.demians@tamil.fr> >Date: Wed, 17 Oct 2012 17:14:17 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 8942 Fix translation of JS strings > containing simple/double quote >Content-Type: text/plain; charset="utf-8" > >With this patch, translated strings containing simple or double quotes >are escaped. 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". > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Confirmed that the example above is handled correctly after >applying the patch and generating a fresh set of French >templates. >--- > 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..3d38af7 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.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8942
:
12907
|
12908
|
12935
|
12939
|
13151
|
13756
|
13757
|
13758
|
14336
|
14337
|
14338
|
14934
|
14935
|
14936
|
15021
|
15058
|
15524
|
17030
|
17031
|
17032
|
17033
|
17034
|
17035