Project update with Python 2.7 โ 3.3.1 and Django 1.4 โ 1.6.2 .
After updating the code, our application starts up again (in py3).
Translations are derived from .mo files.
The only problem is that our old .po files cannot be used with
django-admin.py makemessages -a
It displays beautiful
UnicodeDecodeError: 'ascii' codec can't decode byte...
We can run makemessages
for the first time and get the skeleton files. As soon as we add any non-ASCII translations (วน, รจ, etc.) to msgstr
values, makemessages
will not complete.
(If we run makemessages with higher word patterns with any non-ASCII characters, skipped.)
I found error reports for a similar problem, but they returned in version 1.3.x, but there was nothing for the above versions.
Update, additional information:
Here where the exception occurs:
.. / python 3.3 / subprocess.py line 847
def _translate_newlines(self, data, encoding): data = data.decode(encoding) return data.replace("\r\n", "\n").replace("\r", "\n")
The encoding
value is ANSI_X3.4-1968
. I saved the template files as UTF-8 along with the .po file.
Here is the .po header (only skeleton created automatically from makemessages):
# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR < EMAIL@ADDRESS >, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-02-28 22:42+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME < EMAIL@ADDRESS >\n" "Language-Team: LANGUAGE < LL@li.org >\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
This worked before (same files) under Python 2.7 and Django 1.5
Update # 2
- List item
- New bare project created (django-admin.py startproject blah)
- Included i18n etc.
- Created a single translation (only in settings.py)
- Ran `makemessages -l de
- Py2.7 (#python manage.py makemessages -a) works as expected
- Py3.3 (# python3 manage.py makemessages -a) not working
Perhaps a bug will be fixed, will be updated.