Bugs item #1592627, was opened at 2006-11-08 13:23
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=1592627&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Russell Phillips (avantman42)
Assigned to: Nobody/Anonymous (nobody)
Summary: gettext has problems with .mo files that use non-ASCII chars
Initial Comment:
Hi,
I'm trying to use gettext to internationalise my
project [1], but I'm getting the following error
message with some translations:
"Traceback (most recent call last):
file PanicButton.py line 36 in ?
file Gettext.pyc line 177 in _init_
file Gettext.pyc line 274 in _parse
struct.error : unpack str size does not match format"
The snippet of code that loads the .mo file is below
(full file is at [2]):
<code>
# Code to find & install l10n file
import gettext, os, locale, glob
loc = locale.getdefaultlocale ()
sLocale = loc [0]
#Use translation file with same name as locale if it exists
if (os.path.exists (os.path.join ('locale', sLocale +
'.mo'))):
sLang = os.path.join ('locale', sLocale + '.mo')
else:
#find a .mo file that matches the first part (first
three
characters) of the locale
sMoFiles = glob.glob (os.path.join ('locale',
sLocale [:3] +
'*.mo'))
if (len (sMoFiles) > 0):
sLang = sMoFiles [0]
else:
#Could not find exact or partial match for
locale - use default
translation file (British English)
sLang = os.path.join ('locale', 'en_GB.mo')
lan = gettext.GNUTranslations (open (sLang))
lan.install ()
# End of code to find & install l10n file
</code>
The problem only seems to appear when the translated
file uses non-ASCII characters.
Full sourcecode is available via the SF.net project
page [1], if required. The .po and .mo files are in the
locale directory [3]. The only .mo file that does not
have problems is en_GB.mo
Russ
[1] http://sourceforge.net/projects/panicbutton
[2]
http://panicbutton.cvs.sourceforge.net/panicbutton/panicbutton/PanicButton.py?view=log
[3]
http://panicbutton.cvs.sourceforge.net/panicbutton/panicbutton/locale/
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1592627&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com