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

[PATCH 2/2] gitk: Provide a default mc function if msgcat is not available

From
BHBernt Hansen <bernt@norang.ca>
Date
Oct 24, 2009, 20:20 UTC
Message-ID
<1256415640-10328-3-git-send-email-bernt@norang.ca>
In-Reply-To
<1256415640-10328-1-git-send-email-bernt@norang.ca>

Msgcat is available since Tcl 8.1. For really old versions of Tcl provide a default mc that just returns the text untranslated. This allows the Tcl version check to return the error in a window instead of making Tcl abort when attempting to load the msgcat package.

Signed-off-by: Bernt Hansen <bernt@norang.ca>
---
I'm not sure if we care about Tcl versions older than 8.1 but this at
least shows the error in the window with the [OK] button.
 gitk |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/gitk b/gitk
index d4cd566..bff891d 100755
--- a/gitk
+++ b/gitk
@@ -11019,10 +11019,15 @@ if { [info exists ::env(GITK_MSGSDIR)] } {
 
 ## Internationalization (i18n) through msgcat and gettext. See
 ## http://www.gnu.org/software/gettext/manual/html_node/Tcl.html
-package require msgcat
-namespace import ::msgcat::mc
-## And eventually load the actual message catalog
-::msgcat::mcload $gitk_msgsdir
+if {[catch {package require msgcat}]} {
+    proc mc {arg} {
+	return $arg
+    }
+} else {
+    namespace import ::msgcat::mc
+    ## And eventually load the actual message catalog
+    ::msgcat::mcload $gitk_msgsdir
+}
 
 # Check that Tcl/Tk is recent enough
 if {[catch {package require Tk 8.4} err]} {
-- 
1.6.5.1.69.g36942
Previous: Paul MackerrasNext: Junio C Hamano
Message 7 of 8 in “gitk: Fix error display when Tcl is too old”
  1. 0/2 gitk: Fix error display when Tcl is too oldBernt Hansen, Oct 24, 2009
  2. 1/2 gitk: Initialize msgcat before first useBernt Hansen, Oct 24, 2009
  3. Pat ThoytsOct 31, 2009
  4. Bernt HansenNov 1, 2009
  5. Skip translation of wrong Tcl version textBernt Hansen, Nov 2, 2009
  6. Paul MackerrasNov 3, 2009
  7. 2/2 gitk: Provide a default mc function if msgcat is not availableBernt Hansen, Oct 24, 2009
  8. Junio C HamanoOct 24, 2009

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.