git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to run git-gui always in English?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 23, 2007, 22:45 UTC
Message-ID
<20071023224537.GH14735@spearce.org>
In-Reply-To
<5AD0C329-7136-42A3-9202-865E70A29B65@zib.de>
Steffen Prohaska <prohaska@zib.de> wrote:
Show 16 quoted lines
> On Oct 21, 2007, at 8:47 AM, Steffen Prohaska wrote:
> 
> >How can I switch msysgit's git-gui to English, independently of
> >the language selected for Windows? I recognized that git-gui
> >adjusts to the 'language selection' of Windows. How can I
> >disable this? I want git-gui to always display English. Nothing
> >else, never! I can't help people who use a different language
> >in the gui, because I'll not understand what they are talking
> >about and they'll not understand me.
> 
> And it's even worse. An error in the localization can completely
> break git-gui. Apparently the German localization included in
> msysgit's Git-1.5.3-preview20071019.exe _is_ broken (see
> attached png).
> 
> Shouldn't the localization code be a bit more fault tolerant?
Yes.  This is a possible workaround:
>From 410aa617e7ca8240500e90f0b0389bde7b7b40aa Mon Sep 17 00:00:00 2001
From: Shawn O. Pearce <spearce@spearce.org>
Date: Tue, 23 Oct 2007 18:44:55 -0400
Subject: [PATCH] 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>
---
 git-gui.sh |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index 38c6e59..a7227ac 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} {
-- 
1.5.3.4.1324.ga7925



-- 
Shawn.
Previous: Steffen ProhaskaNext: Peter Karlsson
Message 6 of 11 in “How to run git-gui always in English?”
  1. Steffen ProhaskaOct 21, 2007
  2. Shawn O. PearceOct 21, 2007
  3. Steffen ProhaskaOct 21, 2007
  4. Shawn O. PearceOct 21, 2007
  5. Steffen ProhaskaOct 23, 2007
  6. Shawn O. PearceOct 23, 2007
  7. Peter KarlssonOct 26, 2007
  8. Alex RiesenOct 26, 2007
  9. Peter KarlssonOct 29, 2007
  10. Junio C HamanoOct 30, 2007
  11. Johannes SchindelinOct 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.