Django makemessages errors Unknown encoding "utf8" Django makemessages errors Unknown encoding "utf8" python python

Django makemessages errors Unknown encoding "utf8"


I know this post is outdated but I had the same issue today, and it took me hours to find out why. Maybe people will be in the same case :

My virtualenv is in my django root directory :

Here is my project tree :

DjangoDirectory:

  • my_env
  • Django_App1
  • Django_App2
  • ...
  • ...
  • manage.py

When I launch command :

./manage.py makemessages -l fr 

I get the same error :

Error: errors happened while running xgettext on __init__.py...

In fact, I noticed that xgettext looked into ALL the files in my folder, as well as files in my_env.

So I found the -i flag which ignore files or folders during the makemessages process

So now, with the command below it works like a charm and I don't get the error anymore.

./manage.py makemessages -l fr -i my_env

Hope it will help


Actually yes, I've already had similar problems with makemessages, because on top of every source file I wrote "# coding: utf8". Even though it worked with source compilation, I've had to replace "utf8" with "utf-8" in every file.

If you're not used to makemessages, take care of gettext functions applied to format strings, you will need strings to contain named parameters when there is more than one placeholder."%s" is good"%(max)s" is good too"%(min)s %(max)s" too"%s %s" is not ok.


I've created a ticket for this at http://code.djangoproject.com/ticket/15980.

It appears to be a simple typo in the Django code, the problem being that python treats "utf8" as an alias for "utf-8", but xgettext does not. The problem still exists as of Django r16169 (05/06/11 12:49:06) in SVN.

EDIT: The issue has been fixed now in the Django source (as of May 2011).