@matheusbsbs / matheus-bagliano / commits / 31bb1d1b2d
Fork 0

git-gui: Paper bag fix missing translated strings

The Tcl expression "[append [mc Foo] Bar]" does not return the string "FooBar" after translation; instead it is setting the variable Foo to the value Bar, or if Foo is already defined it is appending Bar onto the end of it. This is *not* what we wanted to have happen here. Tcl's join function is actually the correct function but its default joinStr argument is a single space. Unfortunately all of our call sites do not want an extra space added to their string. So we need a small wrapper function to make the call to join with an empty join string. In C this is (roughly) the job of the strcat function. Since strcat is not yet used at the global level it is a reasonable name to use here. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Sep 14, 2007 at 01:50 UTC 31bb1d1b2d1e893836b0d2b091fed9e39ee84853
9 files changed +34 -30
git-gui.sh
+11 -7
@@ -96,6 +96,10 @@ proc mc {fmt args} {
96 return [eval [list format $fmt] $args]
97 }
98
99 +proc strcat {args} {
100 + return [join $args {}]
101 +}
102 +
103 ::msgcat::mcload $oguimsg
104 unset oguimsg
105
@@ -540,7 +544,7 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
544 -icon error \
545 -type ok \
546 -title [mc "git-gui: fatal error"] \
543 - -message [append [mc "Cannot parse Git version string:"] "\n\n$_git_version"]
547 + -message [strcat [mc "Cannot parse Git version string:"] "\n\n$_git_version"]
548 exit 1
549 }
550
@@ -722,7 +726,7 @@ if {[catch {
726 set _prefix [git rev-parse --show-prefix]
727 } err]} {
728 catch {wm withdraw .}
725 - error_popup [append [mc "Cannot find the git directory:"] "\n\n$err"]
729 + error_popup [strcat [mc "Cannot find the git directory:"] "\n\n$err"]
730 exit 1
731 }
732 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
@@ -730,26 +734,26 @@ if {![file isdirectory $_gitdir] && [is_Cygwin]} {
734 }
735 if {![file isdirectory $_gitdir]} {
736 catch {wm withdraw .}
733 - error_popup [append [mc "Git directory not found:"] "\n\n$_gitdir"]
737 + error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"]
738 exit 1
739 }
740 if {$_prefix ne {}} {
741 regsub -all {[^/]+/} $_prefix ../ cdup
742 if {[catch {cd $cdup} err]} {
743 catch {wm withdraw .}
740 - error_popup [append [mc "Cannot move to top of working directory:"] "\n\n$err"]
744 + error_popup [strcat [mc "Cannot move to top of working directory:"] "\n\n$err"]
745 exit 1
746 }
747 unset cdup
748 } elseif {![is_enabled bare]} {
749 if {[lindex [file split $_gitdir] end] ne {.git}} {
750 catch {wm withdraw .}
747 - error_popup [append [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"]
751 + error_popup [strcat [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"]
752 exit 1
753 }
754 if {[catch {cd [file dirname $_gitdir]} err]} {
755 catch {wm withdraw .}
752 - error_popup [append [mc "No working directory"] " [file dirname $_gitdir]:\n\n$err"]
756 + error_popup [strcat [mc "No working directory"] " [file dirname $_gitdir]:\n\n$err"]
757 exit 1
758 }
759 }
@@ -1658,7 +1662,7 @@ proc apply_config {} {
1662 font configure $font $cn $cv
1663 }
1664 } err]} {
1661 - error_popup [append [mc "Invalid font specified in %s:" "gui.$name"] "\n\n$err"]
1665 + error_popup [strcat [mc "Invalid font specified in %s:" "gui.$name"] "\n\n$err"]
1666 }
1667 foreach {cn cv} [font configure $font] {
1668 font configure ${font}bold $cn $cv
lib/blame.tcl
+6 -6
@@ -784,16 +784,16 @@ method _showcommit {cur_w lno} {
784 }
785
786 $w_cviewer insert end "commit $cmit\n" header_key
787 - $w_cviewer insert end [append [mc "Author:"] "\t"] header_key
787 + $w_cviewer insert end [strcat [mc "Author:"] "\t"] header_key
788 $w_cviewer insert end "$author_name $author_email" header_val
789 $w_cviewer insert end " $author_time\n" header_val
790
791 - $w_cviewer insert end [append [mc "Committer:"] "\t"] header_key
791 + $w_cviewer insert end [strcat [mc "Committer:"] "\t"] header_key
792 $w_cviewer insert end "$committer_name $committer_email" header_val
793 $w_cviewer insert end " $committer_time\n" header_val
794
795 if {$file ne $path} {
796 - $w_cviewer insert end [append [mc "Original File:"] "\t"] header_key
796 + $w_cviewer insert end [strcat [mc "Original File:"] "\t"] header_key
797 $w_cviewer insert end "[escape_path $file]\n" header_val
798 }
799
@@ -907,18 +907,18 @@ method _open_tooltip {cur_w} {
907 catch {set summary $header($cmit,summary)}
908 catch {set author_time [foramt_date $header($cmit,author-time)]}
909
910 - $tooltip_t insert end [append [mc "Originally By:"] "\n"] section_header
910 + $tooltip_t insert end [strcat [mc "Originally By:"] "\n"] section_header
911 $tooltip_t insert end "commit $cmit\n"
912 $tooltip_t insert end "$author_name $author_time\n"
913 $tooltip_t insert end "$summary\n"
914
915 if {$file ne $path} {
916 - $tooltip_t insert end [append [mc "In File:"] " "] section_header
916 + $tooltip_t insert end [strcat [mc "In File:"] " "] section_header
917 $tooltip_t insert end "$file\n"
918 }
919
920 $tooltip_t insert end "\n"
921 - $tooltip_t insert end [append [mc "Copied Or Moved Here By:"] "\n"] section_header
921 + $tooltip_t insert end [strcat [mc "Copied Or Moved Here By:"] "\n"] section_header
922 $tooltip_t insert end $save
923 }
924
lib/branch_rename.tcl
+1 -1
@@ -114,7 +114,7 @@ method _rename {} {
114 -type ok \
115 -title [wm title $w] \
116 -parent $w \
117 - -message [append [mc "Failed to rename '%s'." $oldname] "\n\n$err"]
117 + -message [strcat [mc "Failed to rename '%s'." $oldname] "\n\n$err"]
118 return
119 }
120
lib/checkout_op.tcl
+3 -3
@@ -236,7 +236,7 @@ method _update_ref {} {
236 if {[catch {
237 git update-ref -m $reflog_msg $ref $new $cur
238 } err]} {
239 - _error $this [append [mc "Failed to update '%s'." $newbranch] "\n\n$err"]
239 + _error $this [strcat [mc "Failed to update '%s'." $newbranch] "\n\n$err"]
240 return 0
241 }
242 }
@@ -351,7 +351,7 @@ method _readtree_wait {fd} {
351 set err $readtree_d
352 regsub {^fatal: } $err {} err
353 $::main_status stop [mc "Aborted checkout of '%s' (file level merging is required)." [_name $this]]
354 - warn_popup [append [mc "File level merge required."] "
354 + warn_popup [strcat [mc "File level merge required."] "
355
356 $err
357
@@ -575,7 +575,7 @@ method _toplevel {title} {
575 }
576
577 method _fatal {err} {
578 - error_popup [append [mc "Failed to set current branch.
578 + error_popup [strcat [mc "Failed to set current branch.
579
580 This working directory is only partially switched. We successfully updated your files, but failed to update an internal Git file.
581
lib/choose_rev.tcl
+1 -1
@@ -314,7 +314,7 @@ method commit_or_die {} {
314 }
315
316 set top [winfo toplevel $w]
317 - set msg [append [mc "Invalid revision: %s" [get $this]] "\n\n$err"]
317 + set msg [strcat [mc "Invalid revision: %s" [get $this]] "\n\n$err"]
318 tk_messageBox \
319 -icon error \
320 -type ok \
lib/commit.tcl
+6 -6
@@ -46,7 +46,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
46 }
47 set msg [string trim $msg]
48 } err]} {
49 - error_popup [append [mc "Error loading commit data for amend:"] "\n\n$err"]
49 + error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"]
50 return
51 }
52
@@ -73,12 +73,12 @@ proc committer_ident {} {
73
74 if {$GIT_COMMITTER_IDENT eq {}} {
75 if {[catch {set me [git var GIT_COMMITTER_IDENT]} err]} {
76 - error_popup [append [mc "Unable to obtain your identity:"] "\n\n$err"]
76 + error_popup [strcat [mc "Unable to obtain your identity:"] "\n\n$err"]
77 return {}
78 }
79 if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
80 $me me GIT_COMMITTER_IDENT]} {
81 - error_popup [append [mc "Invalid GIT_COMMITTER_IDENT:"] "\n\n$me"]
81 + error_popup [strcat [mc "Invalid GIT_COMMITTER_IDENT:"] "\n\n$me"]
82 return {}
83 }
84 }
@@ -254,7 +254,7 @@ proc commit_committree {fd_wt curHEAD msg} {
254
255 gets $fd_wt tree_id
256 if {$tree_id eq {} || [catch {close $fd_wt} err]} {
257 - error_popup [append [mc "write-tree failed:"] "\n\n$err"]
257 + error_popup [strcat [mc "write-tree failed:"] "\n\n$err"]
258 ui_status {Commit failed.}
259 unlock_index
260 return
@@ -314,7 +314,7 @@ A rescan will be automatically started now.
314 }
315 lappend cmd <$msg_p
316 if {[catch {set cmt_id [eval git $cmd]} err]} {
317 - error_popup [append [mc "commit-tree failed:"] "\n\n$err"]
317 + error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"]
318 ui_status {Commit failed.}
319 unlock_index
320 return
@@ -336,7 +336,7 @@ A rescan will be automatically started now.
336 if {[catch {
337 git update-ref -m $reflogm HEAD $cmt_id $curHEAD
338 } err]} {
339 - error_popup [append [mc "update-ref failed:"] "\n\n$err"]
339 + error_popup [strcat [mc "update-ref failed:"] "\n\n$err"]
340 ui_status {Commit failed.}
341 unlock_index
342 return
lib/diff.tcl
+2 -2
@@ -112,7 +112,7 @@ proc show_diff {path w {lno {}}} {
112 set diff_active 0
113 unlock_index
114 ui_status [mc "Unable to display %s" [escape_path $path]]
115 - error_popup [append [mc "Error loading file:"] "\n\n$err"]
115 + error_popup [strcat [mc "Error loading file:"] "\n\n$err"]
116 return
117 }
118 $ui_diff conf -state normal
@@ -182,7 +182,7 @@ proc show_diff {path w {lno {}}} {
182 set diff_active 0
183 unlock_index
184 ui_status [mc "Unable to display %s" [escape_path $path]]
185 - error_popup [append [mc "Error loading diff:"] "\n\n$err"]
185 + error_popup [strcat [mc "Error loading diff:"] "\n\n$err"]
186 return
187 }
188
lib/option.tcl
+1 -1
@@ -308,7 +308,7 @@ proc do_restore_defaults {} {
308
309 proc do_save_config {w} {
310 if {[catch {save_config} err]} {
311 - error_popup [append [mc "Failed to completely save options:"] "\n\n$err"]
311 + error_popup [strcat [mc "Failed to completely save options:"] "\n\n$err"]
312 }
313 reshow_diff
314 destroy $w
lib/shortcut.tcl
+3 -3
@@ -23,7 +23,7 @@ proc do_windows_shortcut {} {
23 puts $fd " \"[file normalize $argv0]\""
24 close $fd
25 } err]} {
26 - error_popup [append [mc "Cannot write script:"] "\n\n$err"]
26 + error_popup [strcat [mc "Cannot write script:"] "\n\n$err"]
27 }
28 }
29 }
@@ -71,7 +71,7 @@ proc do_cygwin_shortcut {} {
71 puts $fd " &\""
72 close $fd
73 } err]} {
74 - error_popup [append [mc "Cannot write script:"] "\n\n$err"]
74 + error_popup [strcat [mc "Cannot write script:"] "\n\n$err"]
75 }
76 }
77 }
@@ -146,7 +146,7 @@ proc do_macosx_app {} {
146
147 file attributes $exe -permissions u+x,g+x,o+x
148 } err]} {
149 - error_popup [append [mc "Cannot write icon:"] "\n\n$err"]
149 + error_popup [strcat [mc "Cannot write icon:"] "\n\n$err"]
150 }
151 }
152 }