python gettext example?

"Karl T. Diedrich" <[email protected]>
Newsgroups gmane.comp.python.internationalization
Message-ID <[email protected]>
Hello,
Are there an examples of Python programs using gettext. I am trying to work 
up a simple example so I can internationalize an open source Python project I 
have. 

I think I know how to prepare the source code prepared but I don't understand 
how it all works together.

I put this at the top of files:

from gettext import gettext as _
from gettext import bindtextdomain, textdomain
from os import sep
from locale import setlocale, LC_ALL

LOCALE_PREFIX = "%susr" % (sep)
LOCALE_DIR = "%s%sshare%slocale" % ( LOCALE_PREFIX, sep, sep )
PACKAGE = "deodas"

setlocale( LC_ALL )
bindtextdomain( PACKAGE, LOCALE_DIR )
textdomain( PACKAGE )

# in the code
string = _( u'A sentance to translate.' )

The source code looks like 
module/__init__.py 
module/etc...
po/POTFILES.in
po/es.po
po/es.mo

I used 
	pygettext filename  &
	msgfmt.py es.po 
to pull out the strings and make the translation catalog.  

How do I run the program using a translation file?

-- 
Karl Diedrich
http://deodas.sourceforge.net/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.