U
ulysses
hi,
I want to translate my app to Chinese use gettext module in python22,wxpython.
I have get pot file, use msgfmt convert to mo file. But if I type some line
character , app can't load MO file.
trans = gettext.GNUTranslations(open('en.mo'))
raise a error , error message is "unpack str size does not match format"
exp:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: Mon Aug 25 16:40:30 2003\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: AboutForm.py:56
msgid "Author"
msgstr "chinese character"
#: AboutForm.py:62
msgid "Donate To"
msgstr ""
#: AboutForm.py:70
msgid "Close"
msgstr "chinese character"
If i don't fill 62 , app is ok.
So I debug gettext module. I find following interest question.
-=gettext line 154=-
buf = fp.read()
I sure fp(file object) has open.
It can't read all binary code. buf 's lengh smaller than real file.
exp ,whole file 1000 byte. gettext only read 187 .
So raise unpack error at gettext line 167
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tlen, toff = unpack(ii, buf[transidx:transidx+8])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because request transidx doesn't exit.
then I remove 62 line ,left empty. App can work.
I open the mo file by ultraedit and compare the different .
I notice the read function broken position bytecode is 0x1A
but good mo same position is 0x0A. so I change the bad mo to 0A.
It's work.
It's really crazy .I don't know where and why I get failure.
If you help us explain the puzzle I very appreciate.
Ulysses
I want to translate my app to Chinese use gettext module in python22,wxpython.
I have get pot file, use msgfmt convert to mo file. But if I type some line
character , app can't load MO file.
trans = gettext.GNUTranslations(open('en.mo'))
raise a error , error message is "unpack str size does not match format"
exp:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: Mon Aug 25 16:40:30 2003\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: AboutForm.py:56
msgid "Author"
msgstr "chinese character"
#: AboutForm.py:62
msgid "Donate To"
msgstr ""
#: AboutForm.py:70
msgid "Close"
msgstr "chinese character"
If i don't fill 62 , app is ok.
So I debug gettext module. I find following interest question.
-=gettext line 154=-
buf = fp.read()
I sure fp(file object) has open.
It can't read all binary code. buf 's lengh smaller than real file.
exp ,whole file 1000 byte. gettext only read 187 .
So raise unpack error at gettext line 167
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tlen, toff = unpack(ii, buf[transidx:transidx+8])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because request transidx doesn't exit.
then I remove 62 line ,left empty. App can work.
I open the mo file by ultraedit and compare the different .
I notice the read function broken position bytecode is 0x1A
but good mo same position is 0x0A. so I change the bad mo to 0A.
It's work.
It's really crazy .I don't know where and why I get failure.
If you help us explain the puzzle I very appreciate.
Ulysses