I18n issue with optik
Thorsten Kampe
thorsten at thorstenkampe.de
Sun Apr 1 14:44:37 EDT 2007
* Steven Bethard (Sun, 01 Apr 2007 10:21:40 -0600)
> Thorsten Kampe wrote:
> > * 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)"
>
> I'm not very experienced with internationalization, but if you change::
>
> gettext.install('test')
>
> to::
>
> gettext.install('test', unicode=True)
>
> what happens?
No traceback anymore from optparse but the non-ascii umlauts are
displayed as question marks ("?").
Thorsten
More information about the Python-list
mailing list