[I18n-sig] python gettext example?
Karl T. Diedrich
diedrich@xmission.com
Tue, 1 Jan 2002 13:28:39 -0600
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/