aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-10-23 18:44:55 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-10-26 03:08:37 -0400
commitab0d33c43852b047c2a3e5ae960df9a146363e7c (patch)
tree34204781a92e8cad1e2475d2764781b4760e4306
parentf4e9996b77415707a20a139463c3e3782e2fa48f (diff)
downloadgit-ab0d33c43852b047c2a3e5ae960df9a146363e7c.tar.gz
git-ab0d33c43852b047c2a3e5ae960df9a146363e7c.tar.xz
git-gui: Protect against bad translation strings
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>
-rwxr-xr-xgit-gui.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 38c6e595d..a7227ac1b 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -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} {