Commits

Takayuki Shimizukawa committed 357b5d1

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

Comments (0)

Files changed (3)

+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)
 =========================================
 

sphinx/builders/gettext.py

 
         for template in self.status_iterator(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):
                 origin = MsgOrigin(template, line)
                 self.catalogs['sphinx'].add(msg, origin)

tests/roots/test-intl/_templates/index.html

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