Re: [PATCH 4/5] git-gui: fix incorrect use of Tcl append command

2016-10-03 Thread Pat Thoyts
Vasco Almeida  writes:

>Fix wrong use of append command in strings marked for translation.
>According to Tcl/Tk Documentation [1],
>   append varName ?value value value ...?
>appends all value arguments to the current value of variable varName.
>This means that
>   append "[appname] ([reponame]): " [mc "File Viewer"]
>is setting a variable named "[appname] ([reponame]): " to the output of
>[mc "File Viewer"], rather than returning the concatenation of both
>expressions as one might expect.
>
>The format for some strings enables, for instance, a French translator
>to translate like "%s (%s) : Create Branch" (space before colon).
>Conversely, strings already translated will be marked as fuzzy and the
>translator must update them herself.
>
>For some cases, use alternative way for concatenation instead of using
>strcat procedure defined in git-gui.sh.
>
>Reference: 31bb1d1 ("git-gui: Paper bag fix missing translated strings",
>2007-09-14) fixes the same issue slightly differently.
>
>[1] http://www.tcl.tk/man/tcl/TclCmd/append.htm
>
>Signed-off-by: Vasco Almeida 
>---
> lib/blame.tcl|  2 +-
> lib/branch_checkout.tcl  |  2 +-
> lib/branch_create.tcl|  2 +-
> lib/branch_delete.tcl|  2 +-
> lib/branch_rename.tcl|  2 +-
> lib/browser.tcl  |  4 ++--
> lib/database.tcl |  2 +-
> lib/diff.tcl | 11 +--
> lib/error.tcl|  4 ++--
> lib/merge.tcl|  2 +-
> lib/remote_add.tcl   |  2 +-
> lib/remote_branch_delete.tcl |  2 +-
> lib/shortcut.tcl |  6 +++---
> lib/tools_dlg.tcl|  6 +++---
> lib/transport.tcl|  2 +-
> 15 files changed, 25 insertions(+), 26 deletions(-)
>
>diff --git a/lib/blame.tcl b/lib/blame.tcl
>index b1d15f4..a1aeb8b 100644
>--- a/lib/blame.tcl
>+++ b/lib/blame.tcl
>@@ -70,7 +70,7 @@ constructor new {i_commit i_path i_jump} {
>   set path   $i_path
> 
>   make_toplevel top w
>-  wm title $top [append "[appname] ([reponame]): " [mc "File Viewer"]]
>+  wm title $top [mc "%s (%s): File Viewer" [appname] [reponame]]
> 
>   set font_w [font measure font_diff "0"]
> 
>diff --git a/lib/branch_checkout.tcl b/lib/branch_checkout.tcl
>index 2e459a8..d06037d 100644
>--- a/lib/branch_checkout.tcl
>+++ b/lib/branch_checkout.tcl
>@@ -13,7 +13,7 @@ constructor dialog {} {
>   global use_ttk NS
>   make_dialog top w
>   wm withdraw $w
>-  wm title $top [append "[appname] ([reponame]): " [mc "Checkout Branch"]]
>+  wm title $top [mc "%s (%s): Checkout Branch" [appname] [reponame]]
>   if {$top ne {.}} {
>   wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
>   }
>diff --git a/lib/branch_create.tcl b/lib/branch_create.tcl
>index 4bb9077..ba367d5 100644
>--- a/lib/branch_create.tcl
>+++ b/lib/branch_create.tcl
>@@ -20,7 +20,7 @@ constructor dialog {} {
> 
>   make_dialog top w
>   wm withdraw $w
>-  wm title $top [append "[appname] ([reponame]): " [mc "Create Branch"]]
>+  wm title $top [mc "%s (%s): Create Branch" [appname] [reponame]]
>   if {$top ne {.}} {
>   wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
>   }
>diff --git a/lib/branch_delete.tcl b/lib/branch_delete.tcl
>index 9aef0c9..a505163 100644
>--- a/lib/branch_delete.tcl
>+++ b/lib/branch_delete.tcl
>@@ -13,7 +13,7 @@ constructor dialog {} {
> 
>   make_dialog top w
>   wm withdraw $w
>-  wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch"]]
>+  wm title $top [mc "%s (%s): Delete Branch" [appname] [reponame]]
>   if {$top ne {.}} {
>   wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
>   }
>diff --git a/lib/branch_rename.tcl b/lib/branch_rename.tcl
>index 6e510ec..3a2d79a 100644
>--- a/lib/branch_rename.tcl
>+++ b/lib/branch_rename.tcl
>@@ -12,7 +12,7 @@ constructor dialog {} {
> 
>   make_dialog top w
>   wm withdraw $w
>-  wm title $top [append "[appname] ([reponame]): " [mc "Rename Branch"]]
>+  wm title $top [mc "%s (%s): Rename Branch" [appname] [reponame]]
>   if {$top ne {.}} {
>   wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
>   }
>diff --git a/lib/browser.tcl b/lib/browser.tcl
>index 0328338..1580493 100644
>--- a/lib/browser.tcl
>+++ b/lib/browser.tcl
>@@ -24,7 +24,7 @@ constructor new {commit {path {}}} {
>   global cursor_ptr M1B use_ttk NS
>   make_dialog top w
>   wm withdraw $top
>-  wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]]
>+  wm title $top [mc "%s (%s): File Browser" [appname] [reponame]]
> 
>   if {$path ne {}} {
>   if {[string index $path end] ne {/}} {
>@@ -272,7 +272,7 @@ constructor dialog {} {
>   global use_ttk NS
>   make_dialog top w
>   wm withdraw $top
>-  wm title $top [append "[appname] ([reponame]): " [mc "Browse Branch 
>Files"]]
>+   

[PATCH 4/5] git-gui: fix incorrect use of Tcl append command

2016-05-08 Thread Vasco Almeida
Fix wrong use of append command in strings marked for translation.
According to Tcl/Tk Documentation [1],
append varName ?value value value ...?
appends all value arguments to the current value of variable varName.
This means that
append "[appname] ([reponame]): " [mc "File Viewer"]
is setting a variable named "[appname] ([reponame]): " to the output of
[mc "File Viewer"], rather than returning the concatenation of both
expressions as one might expect.

The format for some strings enables, for instance, a French translator
to translate like "%s (%s) : Create Branch" (space before colon).
Conversely, strings already translated will be marked as fuzzy and the
translator must update them herself.

For some cases, use alternative way for concatenation instead of using
strcat procedure defined in git-gui.sh.

Reference: 31bb1d1 ("git-gui: Paper bag fix missing translated strings",
2007-09-14) fixes the same issue slightly differently.

[1] http://www.tcl.tk/man/tcl/TclCmd/append.htm

Signed-off-by: Vasco Almeida 
---
 lib/blame.tcl|  2 +-
 lib/branch_checkout.tcl  |  2 +-
 lib/branch_create.tcl|  2 +-
 lib/branch_delete.tcl|  2 +-
 lib/branch_rename.tcl|  2 +-
 lib/browser.tcl  |  4 ++--
 lib/database.tcl |  2 +-
 lib/diff.tcl | 11 +--
 lib/error.tcl|  4 ++--
 lib/merge.tcl|  2 +-
 lib/remote_add.tcl   |  2 +-
 lib/remote_branch_delete.tcl |  2 +-
 lib/shortcut.tcl |  6 +++---
 lib/tools_dlg.tcl|  6 +++---
 lib/transport.tcl|  2 +-
 15 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/lib/blame.tcl b/lib/blame.tcl
index b1d15f4..a1aeb8b 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -70,7 +70,7 @@ constructor new {i_commit i_path i_jump} {
set path   $i_path
 
make_toplevel top w
-   wm title $top [append "[appname] ([reponame]): " [mc "File Viewer"]]
+   wm title $top [mc "%s (%s): File Viewer" [appname] [reponame]]
 
set font_w [font measure font_diff "0"]
 
diff --git a/lib/branch_checkout.tcl b/lib/branch_checkout.tcl
index 2e459a8..d06037d 100644
--- a/lib/branch_checkout.tcl
+++ b/lib/branch_checkout.tcl
@@ -13,7 +13,7 @@ constructor dialog {} {
global use_ttk NS
make_dialog top w
wm withdraw $w
-   wm title $top [append "[appname] ([reponame]): " [mc "Checkout Branch"]]
+   wm title $top [mc "%s (%s): Checkout Branch" [appname] [reponame]]
if {$top ne {.}} {
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
}
diff --git a/lib/branch_create.tcl b/lib/branch_create.tcl
index 4bb9077..ba367d5 100644
--- a/lib/branch_create.tcl
+++ b/lib/branch_create.tcl
@@ -20,7 +20,7 @@ constructor dialog {} {
 
make_dialog top w
wm withdraw $w
-   wm title $top [append "[appname] ([reponame]): " [mc "Create Branch"]]
+   wm title $top [mc "%s (%s): Create Branch" [appname] [reponame]]
if {$top ne {.}} {
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
}
diff --git a/lib/branch_delete.tcl b/lib/branch_delete.tcl
index 9aef0c9..a505163 100644
--- a/lib/branch_delete.tcl
+++ b/lib/branch_delete.tcl
@@ -13,7 +13,7 @@ constructor dialog {} {
 
make_dialog top w
wm withdraw $w
-   wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch"]]
+   wm title $top [mc "%s (%s): Delete Branch" [appname] [reponame]]
if {$top ne {.}} {
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
}
diff --git a/lib/branch_rename.tcl b/lib/branch_rename.tcl
index 6e510ec..3a2d79a 100644
--- a/lib/branch_rename.tcl
+++ b/lib/branch_rename.tcl
@@ -12,7 +12,7 @@ constructor dialog {} {
 
make_dialog top w
wm withdraw $w
-   wm title $top [append "[appname] ([reponame]): " [mc "Rename Branch"]]
+   wm title $top [mc "%s (%s): Rename Branch" [appname] [reponame]]
if {$top ne {.}} {
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
}
diff --git a/lib/browser.tcl b/lib/browser.tcl
index 0328338..1580493 100644
--- a/lib/browser.tcl
+++ b/lib/browser.tcl
@@ -24,7 +24,7 @@ constructor new {commit {path {}}} {
global cursor_ptr M1B use_ttk NS
make_dialog top w
wm withdraw $top
-   wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]]
+   wm title $top [mc "%s (%s): File Browser" [appname] [reponame]]
 
if {$path ne {}} {
if {[string index $path end] ne {/}} {
@@ -272,7 +272,7 @@ constructor dialog {} {
global use_ttk NS
make_dialog top w
wm withdraw $top
-   wm title $top [append "[appname] ([reponame]): " [mc "Browse Branch 
Files"]]
+   wm title $top [mc "%s (%s): Browse Branch Files" [appname] [reponame]]
if {$top ne {.}} {
wm