Skip to content

Commit

Permalink
git-gui: Protect against bad translation strings
Browse files Browse the repository at this point in the history
If a translation string uses a format character we don't have an
argument for then it may throw an error when we attempt to format
the translation.  In this case switch back to the default format
that comes with the program (aka the English translation).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Shawn O. Pearce committed Oct 26, 2007
1 parent f4e9996 commit ab0d33c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,20 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {

package require msgcat

proc mc {fmt args} {
set fmt [::msgcat::mc $fmt]
proc _mc_trim {fmt} {
set cmk [string first @@ $fmt]
if {$cmk > 0} {
set fmt [string range $fmt 0 [expr {$cmk - 1}]]
return [string range $fmt 0 [expr {$cmk - 1}]]
}
return [eval [list format $fmt] $args]
return $fmt
}

proc mc {en_fmt args} {
set fmt [_mc_trim [::msgcat::mc $en_fmt]]
if {[catch {set msg [eval [list format $fmt] $args]} err]} {
set msg [eval [list format [_mc_trim $en_fmt]] $args]
}
return $msg
}

proc strcat {args} {
Expand Down

0 comments on commit ab0d33c

Please sign in to comment.