http://mail.python.org/pipermail/python-dev/2006-May/065458.html

ользую UTF-8 в своем редакторе, поэтому все отображаемые здесь строки имеют формат UTF-8

У меня есть сценарий Python, как это:

# -*- coding: utf-8 -*-
...
parser = optparse.OptionParser(
  description=_('automates the dice rolling in the classic game "risk"'), 
  usage=_("usage: %prog attacking defending"))

Затем я использовал xgettext, чтобы получить все и получил файл .pot, который можно свести к следующему:

"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 ""

После этого я использовал msginit, чтобы получитьde.po который я заполнил так:

"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\""

Запустив скрипт, я получаю следующую ошибку:

  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)

Как я могу это исправить?

Ответы на вопрос(1)

Ваш ответ на вопрос