* Re: [PATCH 1/2] gitk: Import msgcat for translation support
@ 2007-07-28 7:28 Brett Schwarz
2007-07-28 10:40 ` Christian Stimming
0 siblings, 1 reply; 4+ messages in thread
From: Brett Schwarz @ 2007-07-28 7:28 UTC (permalink / raw)
To: Paul Mackerras, Christian Stimming; +Cc: git
>
> ----- Original Message ----
> From: Paul Mackerras <paulus@samba.org>
> To: Christian Stimming <stimming@tuhh.de>
> Cc: git@vger.kernel.org
> Sent: Friday, July 27, 2007 4:53:28 PM
> Subject: Re: [PATCH 1/2] gitk: Import msgcat for translation support
>
> Christian Stimming writes:
>
> > Import tcl's msgcat package to have the [mc...] procedure for
> > translation available.
>
> I would prefer
>
> if {[catch {
> package require msgcat
> # rest of your new stuff
> }]} {
> proc mc {str} {
> return $str
> }
> }
>
> so that everything still works if msgcat isn't available. In other
> words I don't want to introduce a possible regression by increasing
> gitk's requirements.
Junio already replied to this, and he was correct. However, this made me think
of something (that probably should be in git-gui as well) to make it a little
more robust. We should check that the msg directory is where we think it is,
and either give a warning, or exit the app (I would vote for the former).
So, something like:
set msgdir [file join . msgs] ;# or whatever this turns out to be
if {[file exists $msgdir]} {
::msgcat::mcload $msgdir
} else {
puts stderr "WTF: can't find message catalog directory"
}
Or you could just use [catch] around the ::msgcat::mcload too.
Regards,
--brett
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] gitk: Import msgcat for translation support
2007-07-28 7:28 [PATCH 1/2] gitk: Import msgcat for translation support Brett Schwarz
@ 2007-07-28 10:40 ` Christian Stimming
0 siblings, 0 replies; 4+ messages in thread
From: Christian Stimming @ 2007-07-28 10:40 UTC (permalink / raw)
To: Brett Schwarz; +Cc: Paul Mackerras, git
Am Samstag, 28. Juli 2007 09:28 schrieb Brett Schwarz:
> > > Import tcl's msgcat package to have the [mc...] procedure for
> > > translation available.
> >
> > if {[catch {
> > package require msgcat
> > # rest of your new stuff
> > }]} {
> > proc mc {str} {
> > return $str
> > }
> > }
> >
> > so that everything still works if msgcat isn't available.
>
> Junio already replied to this, and he was correct.
The conclusion is that tcl8.1 is old enough so that you can safely assume
msgcat exists? Or rather: Gitk probably requires tcl8.1 anyway (is there a
known required tcl version for gitk?), and hence this can be relied upon here
as well.
> However, this made me
> think of something (that probably should be in git-gui as well) to make it
> a little more robust. We should check that the msg directory is where we
> think it is, and either give a warning, or exit the app (I would vote for
> the former).
>From what I've seen during testing, if the directory passed to msgload doesn't
exists, the function simply does nothing. Its documentation doesn't say what
is going to happen on a non-existing directory, though:
http://www.tcl.tk/man/tcl8.4/TclCmd/msgcat.htm#M10
> set msgdir [file join . msgs] ;# or whatever this turns out to be
> if {[file exists $msgdir]} {
> ::msgcat::mcload $msgdir
> } else {
> puts stderr "WTF: can't find message catalog directory"
> }
>
> Or you could just use [catch] around the ::msgcat::mcload too.
I don't think [catch] changes anything, as the function rather seems to be
no-op on nonexisting directory. So I think this wouldn't
improve "robustness". I think this would only help in order to point out to
the user that no translation has been found; however, it can't be known at
this point whether this happens only because no translation exists, or
whether there was some error in the installation. Probably only the latter is
actually interesting to the user.
Well, in conclusion I think the msgcat function is already robust enough and
neither [catch] nor the directory checking buys us anything here.
Christian
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] gitk: Import msgcat for translation support
@ 2007-07-27 14:53 Christian Stimming
2007-07-27 23:53 ` Paul Mackerras
0 siblings, 1 reply; 4+ messages in thread
From: Christian Stimming @ 2007-07-27 14:53 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
Import tcl's msgcat package to have the [mc...] procedure for
translation available.
However, in the current form gitk doesn't load any data a data
directory or from anywhere; if it should load any translation
catalogs, of course it needs to load them from a designated data
directory. For testing, it uses the ./msgs/ subdirectory (marked as
FIXME), but eventually a full-blown data directory needs to be added
there instead.
Signed-off-by: Christian Stimming <stimming@tuhh.de>
---
Actual translation markup will follow.
gitk | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/gitk b/gitk
index 39e452a..c01acfb 100755
--- a/gitk
+++ b/gitk
@@ -7463,6 +7463,13 @@ set fgcolor black
set diffcolors {red "#00a000" blue}
set selectbgcolor gray85
+## 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
+## FIXME: Need to define a suitable msgs/ directory here.
+::msgcat::mcload [file join . msgs]
+
catch {source ~/.gitk}
font create optionfont -family sans-serif -size -12
--
1.5.3.rc2.12.gbc280
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] gitk: Import msgcat for translation support
2007-07-27 14:53 Christian Stimming
@ 2007-07-27 23:53 ` Paul Mackerras
0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2007-07-27 23:53 UTC (permalink / raw)
To: Christian Stimming; +Cc: git
Christian Stimming writes:
> Import tcl's msgcat package to have the [mc...] procedure for
> translation available.
I would prefer
if {[catch {
package require msgcat
# rest of your new stuff
}]} {
proc mc {str} {
return $str
}
}
so that everything still works if msgcat isn't available. In other
words I don't want to introduce a possible regression by increasing
gitk's requirements.
Paul.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-28 10:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-28 7:28 [PATCH 1/2] gitk: Import msgcat for translation support Brett Schwarz
2007-07-28 10:40 ` Christian Stimming
-- strict thread matches above, loose matches on Subject: below --
2007-07-27 14:53 Christian Stimming
2007-07-27 23:53 ` Paul Mackerras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox