From 31bb1d1b2d1e893836b0d2b091fed9e39ee84853 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 14 Sep 2007 01:50:09 -0400 Subject: [PATCH] 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 --- git-gui.sh | 18 +++++++++++------- lib/blame.tcl | 12 ++++++------ lib/branch_rename.tcl | 2 +- lib/checkout_op.tcl | 6 +++--- lib/choose_rev.tcl | 2 +- lib/commit.tcl | 12 ++++++------ lib/diff.tcl | 4 ++-- lib/option.tcl | 2 +- lib/shortcut.tcl | 6 +++--- 9 files changed, 34 insertions(+), 30 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 2d7a2a8..4682487 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -96,6 +96,10 @@ proc mc {fmt args} { return [eval [list format $fmt] $args] } +proc strcat {args} { + return [join $args {}] +} + ::msgcat::mcload $oguimsg unset oguimsg @@ -540,7 +544,7 @@ if {![regsub {^git version } $_git_version {} _git_version]} { -icon error \ -type ok \ -title [mc "git-gui: fatal error"] \ - -message [append [mc "Cannot parse Git version string:"] "\n\n$_git_version"] + -message [strcat [mc "Cannot parse Git version string:"] "\n\n$_git_version"] exit 1 } @@ -722,7 +726,7 @@ if {[catch { set _prefix [git rev-parse --show-prefix] } err]} { catch {wm withdraw .} - error_popup [append [mc "Cannot find the git directory:"] "\n\n$err"] + error_popup [strcat [mc "Cannot find the git directory:"] "\n\n$err"] exit 1 } if {![file isdirectory $_gitdir] && [is_Cygwin]} { @@ -730,26 +734,26 @@ if {![file isdirectory $_gitdir] && [is_Cygwin]} { } if {![file isdirectory $_gitdir]} { catch {wm withdraw .} - error_popup [append [mc "Git directory not found:"] "\n\n$_gitdir"] + error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"] exit 1 } if {$_prefix ne {}} { regsub -all {[^/]+/} $_prefix ../ cdup if {[catch {cd $cdup} err]} { catch {wm withdraw .} - error_popup [append [mc "Cannot move to top of working directory:"] "\n\n$err"] + error_popup [strcat [mc "Cannot move to top of working directory:"] "\n\n$err"] exit 1 } unset cdup } elseif {![is_enabled bare]} { if {[lindex [file split $_gitdir] end] ne {.git}} { catch {wm withdraw .} - error_popup [append [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"] + error_popup [strcat [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"] exit 1 } if {[catch {cd [file dirname $_gitdir]} err]} { catch {wm withdraw .} - error_popup [append [mc "No working directory"] " [file dirname $_gitdir]:\n\n$err"] + error_popup [strcat [mc "No working directory"] " [file dirname $_gitdir]:\n\n$err"] exit 1 } } @@ -1658,7 +1662,7 @@ proc apply_config {} { font configure $font $cn $cv } } err]} { - error_popup [append [mc "Invalid font specified in %s:" "gui.$name"] "\n\n$err"] + error_popup [strcat [mc "Invalid font specified in %s:" "gui.$name"] "\n\n$err"] } foreach {cn cv} [font configure $font] { font configure ${font}bold $cn $cv diff --git a/lib/blame.tcl b/lib/blame.tcl index d14805e..a911c3c 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -784,16 +784,16 @@ method _showcommit {cur_w lno} { } $w_cviewer insert end "commit $cmit\n" header_key - $w_cviewer insert end [append [mc "Author:"] "\t"] header_key + $w_cviewer insert end [strcat [mc "Author:"] "\t"] header_key $w_cviewer insert end "$author_name $author_email" header_val $w_cviewer insert end " $author_time\n" header_val - $w_cviewer insert end [append [mc "Committer:"] "\t"] header_key + $w_cviewer insert end [strcat [mc "Committer:"] "\t"] header_key $w_cviewer insert end "$committer_name $committer_email" header_val $w_cviewer insert end " $committer_time\n" header_val if {$file ne $path} { - $w_cviewer insert end [append [mc "Original File:"] "\t"] header_key + $w_cviewer insert end [strcat [mc "Original File:"] "\t"] header_key $w_cviewer insert end "[escape_path $file]\n" header_val } @@ -907,18 +907,18 @@ method _open_tooltip {cur_w} { catch {set summary $header($cmit,summary)} catch {set author_time [foramt_date $header($cmit,author-time)]} - $tooltip_t insert end [append [mc "Originally By:"] "\n"] section_header + $tooltip_t insert end [strcat [mc "Originally By:"] "\n"] section_header $tooltip_t insert end "commit $cmit\n" $tooltip_t insert end "$author_name $author_time\n" $tooltip_t insert end "$summary\n" if {$file ne $path} { - $tooltip_t insert end [append [mc "In File:"] " "] section_header + $tooltip_t insert end [strcat [mc "In File:"] " "] section_header $tooltip_t insert end "$file\n" } $tooltip_t insert end "\n" - $tooltip_t insert end [append [mc "Copied Or Moved Here By:"] "\n"] section_header + $tooltip_t insert end [strcat [mc "Copied Or Moved Here By:"] "\n"] section_header $tooltip_t insert end $save } diff --git a/lib/branch_rename.tcl b/lib/branch_rename.tcl index d6f040e..1665388 100644 --- a/lib/branch_rename.tcl +++ b/lib/branch_rename.tcl @@ -114,7 +114,7 @@ method _rename {} { -type ok \ -title [wm title $w] \ -parent $w \ - -message [append [mc "Failed to rename '%s'." $oldname] "\n\n$err"] + -message [strcat [mc "Failed to rename '%s'." $oldname] "\n\n$err"] return } diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index a011044..f243966 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -236,7 +236,7 @@ method _update_ref {} { if {[catch { git update-ref -m $reflog_msg $ref $new $cur } err]} { - _error $this [append [mc "Failed to update '%s'." $newbranch] "\n\n$err"] + _error $this [strcat [mc "Failed to update '%s'." $newbranch] "\n\n$err"] return 0 } } @@ -351,7 +351,7 @@ method _readtree_wait {fd} { set err $readtree_d regsub {^fatal: } $err {} err $::main_status stop [mc "Aborted checkout of '%s' (file level merging is required)." [_name $this]] - warn_popup [append [mc "File level merge required."] " + warn_popup [strcat [mc "File level merge required."] " $err @@ -575,7 +575,7 @@ method _toplevel {title} { } method _fatal {err} { - error_popup [append [mc "Failed to set current branch. + error_popup [strcat [mc "Failed to set current branch. This working directory is only partially switched. We successfully updated your files, but failed to update an internal Git file. diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index 5e833a5..a063c5b 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -314,7 +314,7 @@ method commit_or_die {} { } set top [winfo toplevel $w] - set msg [append [mc "Invalid revision: %s" [get $this]] "\n\n$err"] + set msg [strcat [mc "Invalid revision: %s" [get $this]] "\n\n$err"] tk_messageBox \ -icon error \ -type ok \ diff --git a/lib/commit.tcl b/lib/commit.tcl index a037c4f..7099f5c 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -46,7 +46,7 @@ You are currently in the middle of a merge that has not been fully completed. Y } set msg [string trim $msg] } err]} { - error_popup [append [mc "Error loading commit data for amend:"] "\n\n$err"] + error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"] return } @@ -73,12 +73,12 @@ proc committer_ident {} { if {$GIT_COMMITTER_IDENT eq {}} { if {[catch {set me [git var GIT_COMMITTER_IDENT]} err]} { - error_popup [append [mc "Unable to obtain your identity:"] "\n\n$err"] + error_popup [strcat [mc "Unable to obtain your identity:"] "\n\n$err"] return {} } if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \ $me me GIT_COMMITTER_IDENT]} { - error_popup [append [mc "Invalid GIT_COMMITTER_IDENT:"] "\n\n$me"] + error_popup [strcat [mc "Invalid GIT_COMMITTER_IDENT:"] "\n\n$me"] return {} } } @@ -254,7 +254,7 @@ proc commit_committree {fd_wt curHEAD msg} { gets $fd_wt tree_id if {$tree_id eq {} || [catch {close $fd_wt} err]} { - error_popup [append [mc "write-tree failed:"] "\n\n$err"] + error_popup [strcat [mc "write-tree failed:"] "\n\n$err"] ui_status {Commit failed.} unlock_index return @@ -314,7 +314,7 @@ A rescan will be automatically started now. } lappend cmd <$msg_p if {[catch {set cmt_id [eval git $cmd]} err]} { - error_popup [append [mc "commit-tree failed:"] "\n\n$err"] + error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"] ui_status {Commit failed.} unlock_index return @@ -336,7 +336,7 @@ A rescan will be automatically started now. if {[catch { git update-ref -m $reflogm HEAD $cmt_id $curHEAD } err]} { - error_popup [append [mc "update-ref failed:"] "\n\n$err"] + error_popup [strcat [mc "update-ref failed:"] "\n\n$err"] ui_status {Commit failed.} unlock_index return diff --git a/lib/diff.tcl b/lib/diff.tcl index c2ae455..43565e4 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -112,7 +112,7 @@ proc show_diff {path w {lno {}}} { set diff_active 0 unlock_index ui_status [mc "Unable to display %s" [escape_path $path]] - error_popup [append [mc "Error loading file:"] "\n\n$err"] + error_popup [strcat [mc "Error loading file:"] "\n\n$err"] return } $ui_diff conf -state normal @@ -182,7 +182,7 @@ proc show_diff {path w {lno {}}} { set diff_active 0 unlock_index ui_status [mc "Unable to display %s" [escape_path $path]] - error_popup [append [mc "Error loading diff:"] "\n\n$err"] + error_popup [strcat [mc "Error loading diff:"] "\n\n$err"] return } diff --git a/lib/option.tcl b/lib/option.tcl index 03bc08f..12e2979 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -308,7 +308,7 @@ proc do_restore_defaults {} { proc do_save_config {w} { if {[catch {save_config} err]} { - error_popup [append [mc "Failed to completely save options:"] "\n\n$err"] + error_popup [strcat [mc "Failed to completely save options:"] "\n\n$err"] } reshow_diff destroy $w diff --git a/lib/shortcut.tcl b/lib/shortcut.tcl index d0e63a3..a7674a7 100644 --- a/lib/shortcut.tcl +++ b/lib/shortcut.tcl @@ -23,7 +23,7 @@ proc do_windows_shortcut {} { puts $fd " \"[file normalize $argv0]\"" close $fd } err]} { - error_popup [append [mc "Cannot write script:"] "\n\n$err"] + error_popup [strcat [mc "Cannot write script:"] "\n\n$err"] } } } @@ -71,7 +71,7 @@ proc do_cygwin_shortcut {} { puts $fd " &\"" close $fd } err]} { - error_popup [append [mc "Cannot write script:"] "\n\n$err"] + error_popup [strcat [mc "Cannot write script:"] "\n\n$err"] } } } @@ -146,7 +146,7 @@ proc do_macosx_app {} { file attributes $exe -permissions u+x,g+x,o+x } err]} { - error_popup [append [mc "Cannot write icon:"] "\n\n$err"] + error_popup [strcat [mc "Cannot write icon:"] "\n\n$err"] } } } -- 2.11.4.GIT