gettext on Windows

Leo Kislov Leo.Kislov at gmail.com
Sat Oct 28 11:50:32 CEST 2006


russ.phillips.nospam at googlemail.com wrote:
> Martin v. Löwis wrote:
> > russ.phillips.nospam at googlemail.com schrieb:
> > > Traceback (most recent call last):
> > >   File "panicbutton.py", line 36, in ?
> > >     lan = gettext.GNUTranslations (open (sLang, "rb"))
> > >   File "C:\Python24\lib\gettext.py", line 177, in __init__
> > >     self._parse(fp)
> > >   File "C:\Python24\lib\gettext.py", line 280, in _parse
> > >     raise IOError(0, 'File is corrupt', filename)
> > > IOError: [Errno 0] File is corrupt: 'locale\\fr_FR.mo'
> >
> > If it says so, it likely is right. How did you create the file?
>
> I only get the "File is corrupt" error when I changed
>
> lan = gettext.GNUTranslations (open (sLang))

This code definately corrupts .mo files since on windows files are
opened in text mode by default.

> to
>
> lan = gettext.GNUTranslations (open (sLang, "rb"))
>
> Without the "rb" in the open () I get a "struct.error : unpack str size
> does not match format" error (see original post).

struct.error usually means input data doesn't correspond to expected
format.

> The .mo files were created using poEdit (www.poedit.org), and I get the
> same error with various translations, all created by different people.

Try msgunfmt
http://www.gnu.org/software/gettext/manual/html_node/gettext_128.html#SEC128
to see if it can convert your files back to text.

  -- Leo




More information about the Python-list mailing list