Erro UTF-8 com Python e gettext
Uso UTF-8 no meu editor, portanto, todas as strings exibidas aqui são UTF-8 no arquiv
Eu tenho um script python como este:
# -*- coding: utf-8 -*-
...
parser = optparse.OptionParser(
description=_('automates the dice rolling in the classic game "risk"'),
usage=_("usage: %prog attacking defending"))
Em seguida, usei o xgettext para obter tudo e obtive um arquivo .pot que pode ser resumido em:
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: auto_dice.py:16
msgid "automates the dice rolling in the classic game \"risk\""
msgstr ""
Depois disso, usei o msginit para obter umde.po
, que preenchi assim:
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: auto_dice.py:16
msgid "automates the dice rolling in the classic game \"risk\""
msgstr "automatisiert das Würfeln bei \"Risiko\""
Executando o script, recebo o seguinte erro:
File "/usr/lib/python2.6/optparse.py", line 1664, in print_help
file.write(self.format_help().encode(encoding, "replace"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 60: ordinal not in range(128)
Como posso corrigir isso?