[ python-Bugs-854589 ] Can't use GetText in win32,i386

SourceForge.net noreply at sourceforge.net
Fri Dec 5 03:36:54 EST 2003


Bugs item #854589, was opened at 2003-12-05 08:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=854589&group_id=5470

Category: Extension Modules
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: ulysses hung (ulyssesh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Can't use GetText in win32,i386

Initial Comment:
hi,

I want to translate my app to Germany use gettext 
module in python22,wxpython.
I have generated pot file, use msgfmt.py 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 at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\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 
read 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. 

I enclosed a small app to test it.
ge.mo is good file.  gebad.mo is damage file.
please see the different ge.po with gebad.po.

Thanks.

Ulysses


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=854589&group_id=5470



More information about the Python-bugs-list mailing list