I18n issue with optik
Thorsten Kampe
thorsten at thorstenkampe.de
Sun Apr 1 09:39:50 EDT 2007
* Steven Bethard (Sat, 31 Mar 2007 20:08:45 -0600)
> Thorsten Kampe wrote:
> > I've written a script which uses Optik/Optparse to display the
> > options (which works fine). The text for the help message is localised
> > (with german umlauts) and when I execute the script with the localised
> > environment variable set, I get this traceback[1]. The interesting
> > thing is that the localised optparse messages from displays fine -
> > it's only my localisation that errors.
> >
> > From my understanding, my script doesn't put out anything, it's
> > optik/optparse who does that. My po file is directly copied from the
> > optik po file (who displays fine) and modified so the po file should
> > be fine, too.
> >
> > What can I do to troubleshoot whether the culprit is my script, optik
> > or gettext?
> >
> > Would it make sense to post the script and the mo or po files?
>
> Yes, probably. Though if you can reduce it to the simplest test case
> that produces the error, it'll increase your chances of having someone
> look at it.
The most simple test.py is:
###
#! /usr/bin/env python
import gettext, \
os, \
sys
gettext.textdomain('optparse')
gettext.install('test')
from optparse import OptionParser, \
OptionGroup
cmdlineparser = OptionParser(description = _('THIS SOFTWARE COMES
WITHOUT WARRANTY, LIABILITY OR SUPPORT!'))
options, args = cmdlineparser.parse_args()
###
When I run LANGUAGE=de ./test.py --help I get the error.
### This is the test.de.po file
# Copyright (C) 2006 Thorsten Kampe
# Thorsten Kampe <thorsten at thorstenkampe.de>, 2006
msgid ""
msgstr ""
"Project-Id-Version: Template 1.0\n"
"POT-Creation-Date: Tue Sep 7 22:20:34 2004\n"
"PO-Revision-Date: 2005-07-03 16:47+0200\n"
"Last-Translator: Thorsten Kampe <thorsten at thorstenkampe.de>\n"
"Language-Team: Thorsten Kampe <thorsten at thorstenkampe.de>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"Content-Transfer-Encoding: 8-bit\n"
"Generated-By: pygettext.py 1.5\n"
msgid "THIS SOFTWARE COMES WITHOUT WARRANTY, LIABILITY OR SUPPORT!"
msgstr "DIESES PROGRAMM HAT WEDER GEWÄHRLEISTUNG, HAFTUNG NOCH
UNTERSTÜTZUNG!"
###
The localisation now produces an error in the localised optik files,
too.
Under Windows I get " File "G:\program files\python\lib\encodings
\cp1252.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table)"
Is there something I have to do to put the terminal in "non-ascii
output mode"?
I tried
###
#! /usr/bin/env python
# -*- coding: ISO-8859-15 -*-
print "DIESES PROGRAMM HAT WEDER GEWÄHRLEISTUNG, HAFTUNG NOCH
UNTERSTÜTZUNG!"
###
...and this worked. That means that my terminal is willing to print,
right?!
> You could also try posting to the optik list:
> http://lists.sourceforge.net/lists/listinfo/optik-users
I already did this via Gmane (although the list seems pretty dead to
me). Sourceforge seems to have a bigger problem as [1] and [2] error.
Sorry for the confusion but this Unicode magic is far from being
rational. I guess most people just don't get it...
Thorsten
[1] http://sourceforge.net/mailarchive/forum.php?forum=optik-users
[2] https://lists.sourceforge.net/lists/listinfo
More information about the Python-list
mailing list