Skip to content

Commit a3d97af

Browse files
vascoolpatthoyts
authored andcommitted
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 <[email protected]> Signed-off-by: Pat Thoyts <[email protected]>
1 parent 43c65a8 commit a3d97af

15 files changed

+25
-26
lines changed

lib/blame.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ constructor new {i_commit i_path i_jump} {
7070
set path $i_path
7171

7272
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]]
7474

7575
set font_w [font measure font_diff "0"]
7676

lib/branch_checkout.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ constructor dialog {} {
1313
global use_ttk NS
1414
make_dialog top w
1515
wm withdraw $w
16-
wm title $top [append "[appname] ([reponame]): " [mc "Checkout Branch"]]
16+
wm title $top [mc "%s (%s): Checkout Branch" [appname] [reponame]]
1717
if {$top ne {.}} {
1818
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
1919
}

lib/branch_create.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ constructor dialog {} {
2020

2121
make_dialog top w
2222
wm withdraw $w
23-
wm title $top [append "[appname] ([reponame]): " [mc "Create Branch"]]
23+
wm title $top [mc "%s (%s): Create Branch" [appname] [reponame]]
2424
if {$top ne {.}} {
2525
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
2626
}

lib/branch_delete.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ constructor dialog {} {
1313

1414
make_dialog top w
1515
wm withdraw $w
16-
wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch"]]
16+
wm title $top [mc "%s (%s): Delete Branch" [appname] [reponame]]
1717
if {$top ne {.}} {
1818
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
1919
}

lib/branch_rename.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ constructor dialog {} {
1212

1313
make_dialog top w
1414
wm withdraw $w
15-
wm title $top [append "[appname] ([reponame]): " [mc "Rename Branch"]]
15+
wm title $top [mc "%s (%s): Rename Branch" [appname] [reponame]]
1616
if {$top ne {.}} {
1717
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
1818
}

lib/browser.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ constructor new {commit {path {}}} {
2424
global cursor_ptr M1B use_ttk NS
2525
make_dialog top w
2626
wm withdraw $top
27-
wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]]
27+
wm title $top [mc "%s (%s): File Browser" [appname] [reponame]]
2828

2929
if {$path ne {}} {
3030
if {[string index $path end] ne {/}} {
@@ -272,7 +272,7 @@ constructor dialog {} {
272272
global use_ttk NS
273273
make_dialog top w
274274
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]]
276276
if {$top ne {.}} {
277277
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
278278
wm transient $top .

lib/database.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ proc do_stats {} {
6363
bind $w <Visibility> "grab $w; focus $w.buttons.close"
6464
bind $w <Key-Escape> [list destroy $w]
6565
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]]
6767
wm deiconify $w
6868
tkwait window $w
6969
}

lib/diff.tcl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ proc show_other_diff {path w m cont_info} {
223223
}
224224
$ui_diff conf -state normal
225225
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
230229
} elseif {![catch {set type [exec file $path]}]} {
231230
set n [string length $path]
232231
if {[string equal -length $n $path $type]} {
@@ -611,7 +610,7 @@ proc apply_hunk {x y} {
611610
puts -nonewline $p $current_diff_header
612611
puts -nonewline $p [$ui_diff get $s_lno $e_lno]
613612
close $p} err]} {
614-
error_popup [append $failed_msg "\n\n$err"]
613+
error_popup "$failed_msg\n\n$err"
615614
unlock_index
616615
return
617616
}
@@ -829,7 +828,7 @@ proc apply_range_or_line {x y} {
829828
puts -nonewline $p $current_diff_header
830829
puts -nonewline $p $wholepatch
831830
close $p} err]} {
832-
error_popup [append $failed_msg "\n\n$err"]
831+
error_popup "$failed_msg\n\n$err"
833832
}
834833

835834
unlock_index

lib/error.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ proc error_popup {msg} {
1717
set cmd [list tk_messageBox \
1818
-icon error \
1919
-type ok \
20-
-title [append "$title: " [mc "error"]] \
20+
-title [mc "%s: error" $title] \
2121
-message $msg]
2222
if {[winfo ismapped [_error_parent]]} {
2323
lappend cmd -parent [_error_parent]
@@ -33,7 +33,7 @@ proc warn_popup {msg} {
3333
set cmd [list tk_messageBox \
3434
-icon warning \
3535
-type ok \
36-
-title [append "$title: " [mc "warning"]] \
36+
-title [mc "%s: warning" $title] \
3737
-message $msg]
3838
if {[winfo ismapped [_error_parent]]} {
3939
lappend cmd -parent [_error_parent]

lib/merge.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ constructor dialog {} {
144144
}
145145

146146
make_dialog top w
147-
wm title $top [append "[appname] ([reponame]): " [mc "Merge"]]
147+
wm title $top [mc "%s (%s): Merge" [appname] [reponame]]
148148
if {$top ne {.}} {
149149
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
150150
}

0 commit comments

Comments
 (0)