There is a gettext module included with gnome-python. It is fairly
similar to the C API, but has some problems with big endian architectures
at the moment (this will be fixed).
You can use it like so:
import gettext
_ = gettext.gettext
gettext.bindtextdomain("translation-domain", "/usr/share/locale")
gettext.textdomain("translation-domain")
print _("Hello world")
If you make the translated strings look like C strings (that is, use
double quotes and no triple quotes, etc), you should be able to use the
standard xgettext program to extract strings.
Alternatively, if you can get your program to translate every string
during its run (difficult if you are trying to translate error messages),
you can set the PY_XGETTEXT environment variable to a file name. Then the
gettext module will work in reverse and output each translated string to
the file named in PY_XGETTEXT. It outputs in standard PO file format,
complete with module name, function name and line number.
You can also use the gettext module for creating or editing message
catalogs:
cat = gettext.Catalog('translation-domain')
cat['Hello world'] = 'hello-world-in-some-other-language'
cat.save('filename.mo')
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
On Sun, 5 Mar 2000, Daniel Kornhauser wrote:
> Hi pythoneers:
>
> I'm making a PyGnomeHello a shamessly python copy fo the GnomeHello of
> the GGAD book.
> I think that the directory structure and GNU instalation utilities could
> be usefull for proving order in the pygnome applications.
>
> I think that it would help avoiding the work of custom instalation
> utilites like the GMath_install.py. But perhaps the application's author
> would like more to do their own intalation srcipts.
>
> Anyway, my problem is to how make internationalization work in python.
> I don't know if it would be prudent to use gettext on python programs
> and how to avoid python parsing errors with N_. It should be foolish to
> have to run a python program throught some kind of preprocesor in order to
> make it workable.
>
> So I'm hopping for replies encouraging my mediocrity saying
> " skip the internationalazion and include the PyGnomeHello in the
> tutorial" or a viable solution using gettext or some other program for
> internationalization.
>
> Thanks a lot
>
> Daniel Kornhauser
>
>
>
>
>
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
>
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]