git-gui: fix incorrect use of Tcl append command

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 <vascomalmeida@sapo.pt> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

Vasco Almeida committed May 8, 2016 at 10:52 UTC a3d97afaa8b4187d62496ccc9cf268e8bd47c5db
15 files changed +25 -26
lib/blame.tcl
+1 -1
@@ -70,7 +70,7 @@ constructor new {i_commit i_path i_jump} {
70 set path $i_path
71
72 make_toplevel top w
73 - wm title $top [append "[appname] ([reponame]): " [mc "File Viewer"]]
73 + wm title $top [mc "%s (%s): File Viewer" [appname] [reponame]]
74
75 set font_w [font measure font_diff "0"]
76
lib/branch_checkout.tcl
+1 -1
@@ -13,7 +13,7 @@ constructor dialog {} {
13 global use_ttk NS
14 make_dialog top w
15 wm withdraw $w
16 - wm title $top [append "[appname] ([reponame]): " [mc "Checkout Branch"]]
16 + wm title $top [mc "%s (%s): Checkout Branch" [appname] [reponame]]
17 if {$top ne {.}} {
18 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
19 }
lib/branch_create.tcl
+1 -1
@@ -20,7 +20,7 @@ constructor dialog {} {
20
21 make_dialog top w
22 wm withdraw $w
23 - wm title $top [append "[appname] ([reponame]): " [mc "Create Branch"]]
23 + wm title $top [mc "%s (%s): Create Branch" [appname] [reponame]]
24 if {$top ne {.}} {
25 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
26 }
lib/branch_delete.tcl
+1 -1
@@ -13,7 +13,7 @@ constructor dialog {} {
13
14 make_dialog top w
15 wm withdraw $w
16 - wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch"]]
16 + wm title $top [mc "%s (%s): Delete Branch" [appname] [reponame]]
17 if {$top ne {.}} {
18 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
19 }
lib/branch_rename.tcl
+1 -1
@@ -12,7 +12,7 @@ constructor dialog {} {
12
13 make_dialog top w
14 wm withdraw $w
15 - wm title $top [append "[appname] ([reponame]): " [mc "Rename Branch"]]
15 + wm title $top [mc "%s (%s): Rename Branch" [appname] [reponame]]
16 if {$top ne {.}} {
17 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
18 }
lib/browser.tcl
+2 -2
@@ -24,7 +24,7 @@ constructor new {commit {path {}}} {
24 global cursor_ptr M1B use_ttk NS
25 make_dialog top w
26 wm withdraw $top
27 - wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]]
27 + wm title $top [mc "%s (%s): File Browser" [appname] [reponame]]
28
29 if {$path ne {}} {
30 if {[string index $path end] ne {/}} {
@@ -272,7 +272,7 @@ constructor dialog {} {
272 global use_ttk NS
273 make_dialog top w
274 wm withdraw $top
275 - wm title $top [append "[appname] ([reponame]): " [mc "Browse Branch Files"]]
275 + wm title $top [mc "%s (%s): Browse Branch Files" [appname] [reponame]]
276 if {$top ne {.}} {
277 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
278 wm transient $top .
lib/database.tcl
+1 -1
@@ -63,7 +63,7 @@ proc do_stats {} {
63 bind $w <Visibility> "grab $w; focus $w.buttons.close"
64 bind $w <Key-Escape> [list destroy $w]
65 bind $w <Key-Return> [list destroy $w]
66 - wm title $w [append "[appname] ([reponame]): " [mc "Database Statistics"]]
66 + wm title $w [mc "%s (%s): Database Statistics" [appname] [reponame]]
67 wm deiconify $w
68 tkwait window $w
69 }
lib/diff.tcl
+5 -6
@@ -223,10 +223,9 @@ proc show_other_diff {path w m cont_info} {
223 }
224 $ui_diff conf -state normal
225 if {$type eq {submodule}} {
226 - $ui_diff insert end [append \
227 - "* " \
228 - [mc "Git Repository (subproject)"] \
229 - "\n"] d_info
226 + $ui_diff insert end \
227 + "* [mc "Git Repository (subproject)"]\n" \
228 + d_info
229 } elseif {![catch {set type [exec file $path]}]} {
230 set n [string length $path]
231 if {[string equal -length $n $path $type]} {
@@ -611,7 +610,7 @@ proc apply_hunk {x y} {
610 puts -nonewline $p $current_diff_header
611 puts -nonewline $p [$ui_diff get $s_lno $e_lno]
612 close $p} err]} {
614 - error_popup [append $failed_msg "\n\n$err"]
613 + error_popup "$failed_msg\n\n$err"
614 unlock_index
615 return
616 }
@@ -829,7 +828,7 @@ proc apply_range_or_line {x y} {
828 puts -nonewline $p $current_diff_header
829 puts -nonewline $p $wholepatch
830 close $p} err]} {
832 - error_popup [append $failed_msg "\n\n$err"]
831 + error_popup "$failed_msg\n\n$err"
832 }
833
834 unlock_index
lib/error.tcl
+2 -2
@@ -17,7 +17,7 @@ proc error_popup {msg} {
17 set cmd [list tk_messageBox \
18 -icon error \
19 -type ok \
20 - -title [append "$title: " [mc "error"]] \
20 + -title [mc "%s: error" $title] \
21 -message $msg]
22 if {[winfo ismapped [_error_parent]]} {
23 lappend cmd -parent [_error_parent]
@@ -33,7 +33,7 @@ proc warn_popup {msg} {
33 set cmd [list tk_messageBox \
34 -icon warning \
35 -type ok \
36 - -title [append "$title: " [mc "warning"]] \
36 + -title [mc "%s: warning" $title] \
37 -message $msg]
38 if {[winfo ismapped [_error_parent]]} {
39 lappend cmd -parent [_error_parent]
lib/merge.tcl
+1 -1
@@ -144,7 +144,7 @@ constructor dialog {} {
144 }
145
146 make_dialog top w
147 - wm title $top [append "[appname] ([reponame]): " [mc "Merge"]]
147 + wm title $top [mc "%s (%s): Merge" [appname] [reponame]]
148 if {$top ne {.}} {
149 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
150 }
lib/remote_add.tcl
+1 -1
@@ -17,7 +17,7 @@ constructor dialog {} {
17
18 make_dialog top w
19 wm withdraw $top
20 - wm title $top [append "[appname] ([reponame]): " [mc "Add Remote"]]
20 + wm title $top [mc "%s (%s): Add Remote" [appname] [reponame]]
21 if {$top ne {.}} {
22 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
23 }
lib/remote_branch_delete.tcl
+1 -1
@@ -26,7 +26,7 @@ constructor dialog {} {
26 global all_remotes M1B use_ttk NS
27
28 make_dialog top w
29 - wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch Remotely"]]
29 + wm title $top [mc "%s (%s): Delete Branch Remotely" [appname] [reponame]]
30 if {$top ne {.}} {
31 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
32 }
lib/shortcut.tcl
+3 -3
@@ -5,7 +5,7 @@ proc do_windows_shortcut {} {
5 global _gitworktree
6 set fn [tk_getSaveFile \
7 -parent . \
8 - -title [append "[appname] ([reponame]): " [mc "Create Desktop Icon"]] \
8 + -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
9 -initialfile "Git [reponame].lnk"]
10 if {$fn != {}} {
11 if {[file extension $fn] ne {.lnk}} {
@@ -40,7 +40,7 @@ proc do_cygwin_shortcut {} {
40 }
41 set fn [tk_getSaveFile \
42 -parent . \
43 - -title [append "[appname] ([reponame]): " [mc "Create Desktop Icon"]] \
43 + -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
44 -initialdir $desktop \
45 -initialfile "Git [reponame].lnk"]
46 if {$fn != {}} {
@@ -72,7 +72,7 @@ proc do_macosx_app {} {
72
73 set fn [tk_getSaveFile \
74 -parent . \
75 - -title [append "[appname] ([reponame]): " [mc "Create Desktop Icon"]] \
75 + -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
76 -initialdir [file join $env(HOME) Desktop] \
77 -initialfile "Git [reponame].app"]
78 if {$fn != {}} {
lib/tools_dlg.tcl
+3 -3
@@ -19,7 +19,7 @@ constructor dialog {} {
19 global repo_config use_ttk NS
20
21 make_dialog top w
22 - wm title $top [append "[appname] ([reponame]): " [mc "Add Tool"]]
22 + wm title $top [mc "%s (%s): Add Tool" [appname] [reponame]]
23 if {$top ne {.}} {
24 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
25 wm transient $top .
@@ -184,7 +184,7 @@ constructor dialog {} {
184 load_config 1
185
186 make_dialog top w
187 - wm title $top [append "[appname] ([reponame]): " [mc "Remove Tool"]]
187 + wm title $top [mc "%s (%s): Remove Tool" [appname] [reponame]]
188 if {$top ne {.}} {
189 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
190 wm transient $top .
@@ -280,7 +280,7 @@ constructor dialog {fullname} {
280 }
281
282 make_dialog top w -autodelete 0
283 - wm title $top [append "[appname] ([reponame]): " $title]
283 + wm title $top "[mc "%s (%s):" [appname] [reponame]] $title"
284 if {$top ne {.}} {
285 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
286 wm transient $top .
lib/transport.tcl
+1 -1
@@ -226,7 +226,7 @@ proc do_push_anywhere {} {
226 bind $w <Visibility> "grab $w; focus $w.buttons.create"
227 bind $w <Key-Escape> "destroy $w"
228 bind $w <Key-Return> [list start_push_anywhere_action $w]
229 - wm title $w [append "[appname] ([reponame]): " [mc "Push"]]
229 + wm title $w [mc "%s (%s): Push" [appname] [reponame]]
230 wm deiconify $w
231 tkwait window $w
232 }