Fix: 'make gettext' cause UnicodeDecodeError when templates contain utf-8 encoded string.

This commit is contained in:
Takayuki Shimizukawa 2013-04-13 22:44:37 +09:00
parent b0b81d194d
commit b91f70be6e
3 changed files with 16 additions and 1 deletions

10
CHANGES
View File

@ -1,3 +1,13 @@
Release 1.2 (in development)
============================
Bugs fixed
----------
* Fix: 'make gettext' cause UnicodeDecodeError when templates contain utf-8
encoded string.
Release 1.2 (beta1 released Mar 31, 2013) Release 1.2 (beta1 released Mar 31, 2013)
========================================= =========================================

View File

@ -139,7 +139,7 @@ class MessageCatalogBuilder(I18nBuilder):
for template in self.status_iterator(files, for template in self.status_iterator(files,
'reading templates... ', purple, len(files)): 'reading templates... ', purple, len(files)):
context = open(template, 'rt').read() #TODO: encoding context = open(template, 'r', encoding='utf-8').read()
for line, meth, msg in extract_translations(context): for line, meth, msg in extract_translations(context):
origin = MsgOrigin(template, line) origin = MsgOrigin(template, line)
self.catalogs['sphinx'].add(msg, origin) self.catalogs['sphinx'].add(msg, origin)

View File

@ -3,3 +3,8 @@
<h1>{{ _('Welcome') }}</h1> <h1>{{ _('Welcome') }}</h1>
<p>{%trans%}Sphinx {{ version }}{%endtrans%}</p> <p>{%trans%}Sphinx {{ version }}{%endtrans%}</p>
{% endblock %} {% endblock %}
{% block comment %}
utf-8 encoded string: ニシキヘビ
{% endblock %}