threads / patch / 9143

patchgit-gui-i18n: Fix translation of the context menu

Subject: [PATCH] git-gui-i18n: Fix translation of the context menu

## tl;dr

3 messages between Jul 22, 2007 and Jul 23, 2007. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Johannes Schindelin· Jul 22, 2007, 16:20 UTC · lore

There is some funny code generation going on to make the context menu, and the messages for this have to be doubly quoted.

Noticed by Harri Ilari Tapio Liusvaara
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-gui.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to git-gui.sh +2 −2
diff --git a/git-gui.sh b/git-gui.sh
index 075a2b9..52170ee 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2457,9 +2457,9 @@ bind_button3 $ui_diff "
 	set cursorX %x
 	set cursorY %y
 	if {\$ui_index eq \$current_diff_side} {
-		$ctxm entryconf $ui_diff_applyhunk -label [mc {Unstage Hunk From Commit}]
+		$ctxm entryconf $ui_diff_applyhunk -label \"[mc "Unstage Hunk From Commit"]\"
 	} else {
-		$ctxm entryconf $ui_diff_applyhunk -label [mc {Stage Hunk For Commit}]
+		$ctxm entryconf $ui_diff_applyhunk -label \"[mc "Stage Hunk For Commit"]\"
 	}
 	tk_popup $ctxm %X %Y
 "
-- 
1.5.3.rc2.29.gc4640f
Shawn O. Pearce· Jul 23, 2007, 03:51 UTC · re: Johannes Schindelin · lore

Re: [PATCH] git-gui-i18n: Fix translation of the context menu

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 10 quoted lines
> 
> There is some funny code generation going on to make the context menu,
> and the messages for this have to be doubly quoted.
> 
> Noticed by Harri Ilari Tapio Liusvaara
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  git-gui.sh |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
I'll try to rewrite this hunk as a procedure, to get rid of the
double evaluation problem.  However...
 
Show 10 quoted lines
> diff --git a/git-gui.sh b/git-gui.sh
> index 075a2b9..52170ee 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -2457,9 +2457,9 @@ bind_button3 $ui_diff "
>  	set cursorX %x
>  	set cursorY %y
>  	if {\$ui_index eq \$current_diff_side} {
> -		$ctxm entryconf $ui_diff_applyhunk -label [mc {Unstage Hunk From Commit}]
> +		$ctxm entryconf $ui_diff_applyhunk -label \"[mc "Unstage Hunk From Commit"]\"

That's the wrong change to do here, as you are going to eval the result of the translation. If the translation had a Tcl special character (\, $, [) in it then we'd actually execute that. Instead the [ should be escaped:

> +		$ctxm entryconf $ui_diff_applyhunk -label \[mc "Unstage Hunk From Commit"\]
But you aren't a Tcl programmer, so its OK.  ;-)
-- 
Shawn.
Johannes Schindelin· Jul 23, 2007, 09:58 UTC · re: Shawn O. Pearce · lore

Re: [PATCH] git-gui-i18n: Fix translation of the context menu

Hi,
On Sun, 22 Jul 2007, Shawn O. Pearce wrote:
Show 21 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > diff --git a/git-gui.sh b/git-gui.sh
> > index 075a2b9..52170ee 100755
> > --- a/git-gui.sh
> > +++ b/git-gui.sh
> > @@ -2457,9 +2457,9 @@ bind_button3 $ui_diff "
> >  	set cursorX %x
> >  	set cursorY %y
> >  	if {\$ui_index eq \$current_diff_side} {
> > -		$ctxm entryconf $ui_diff_applyhunk -label [mc {Unstage Hunk From Commit}]
> > +		$ctxm entryconf $ui_diff_applyhunk -label \"[mc "Unstage Hunk From Commit"]\"
> 
> That's the wrong change to do here, as you are going to eval
> the result of the translation.  If the translation had a Tcl
> special character (\, $, [) in it then we'd actually execute that.
> Instead the [ should be escaped:
> 
> > +		$ctxm entryconf $ui_diff_applyhunk -label \[mc "Unstage Hunk From Commit"\]
> 
> But you aren't a Tcl programmer, so its OK.  ;-)
Heh.

Thanks, Dscho

← back to recent threads