internationalisation/gettext - any sample (.MO) data available ?

"Martin v. Löwis" martin at v.loewis.de
Fri Feb 6 01:54:18 EST 2004


Richard Shea wrote:
> I also wanted to double-check a couple of things. I've got my a.py in
> one directory and the python installation in another (that's just the
> way I do stuff on this machine) when you said ...

As a starting point, you should make sure it really finds the .mo file.
The example is constructed so that the directory containing a.py must
be the current directory.

On Unix, you can use strace to find out where it looks for the .mo file,
or you can add print messages to gettext.py.

> ... I presumed that was relative to a.py not the python interpreter ?
> Is that correct ? That is if I have C:\richardspythonsrc\a.py I should
> have C:\richardspythonsrc\de\LC_MESSAGES\demoapp.mo ?

Correct.

> Also I'm working on a WIN32 machine so to achieve ...
> 
>>Set the LANG environment variable to de_DE.ISO-8859-1, and
>>invoke
> 
> 
> ... I put ...
> 
> import locale
> locale.setlocale(locale.LC_ALL, 'german')
> 
> ... up at the top of a.py - is that what you would advise ?

No. Set the LANG environment variable, using the SET command
of cmd.exe, or changing Properties of My Computer.

There are other ways to programmatically specify the desired
language, but invoking setlocale is none of them.

Regards,
Martin




More information about the Python-list mailing list