makemessages create invalid msgid in django.po file

48 views
Skip to first unread message

Chuck Bai2

unread,
Oct 13, 2008, 12:37:34 AM10/13/08
to django...@googlegroups.com
The base language of my site is Chinese. I want to change to English
when user select language perferrence.

In my base.html, I have
{% trans "产品" %}

I generated django.po file using
django-admin.py makemessages -l en

In django.po file of en locale,
#: .\templates\base.html.py:36
msgid "å…¬å ¸äº§å“ "
msgstr "Products"

As you can see, the generated msgid is scrambled and invalid. This
caused translation failed. If I manually changed the msgid to be
msgid "产品"
msgstr "Products"

The translation works. I verified that my base.html is utf-8 encoded.
Anyone know what is the reason for the scrambled msgid in django.po
file? I suspect this is an encoding issue on makemessages command, but
don't know how to resolve this.

Karen Tracey

unread,
Oct 13, 2008, 9:34:09 AM10/13/08
to django...@googlegroups.com

You don't mention your system type but given the backslashes in the path name I'm guessing Windows.  In which case it's likely you are hitting this:

http://code.djangoproject.com/ticket/9212

(Even if you are not running Windows you could hit this if your gettext package is earlier than 0.15.  Look at the output of 'xgettext --version' to see if this is what you are hitting.  If it's lower than 0.15 then this is likely the problem.)

The bug is in xgettext and was fixed in xgettext 0.15.  Unfortunately the most-easily installed gettext utilities binaries for Windows are older than that.  Therefore we put a fix into Django to work around the xgettext bug, but this problem was reported after 1.0 was shipped so you'll have to run with a 1.0.X branch or trunk checkout in order to get it.  Alternatively you could install a gettext package that is 0.15 level or higher (the one that cygwin installs, for example, does not have this problem).

Karen

Chuck22

unread,
Oct 13, 2008, 11:07:45 PM10/13/08
to Django users
Thanks, Karen. You are correct. My version is Win32 binaries of GNU
gettext-runtime 0.13.1. It seems getting the development trunck is a
better choice for me. But, I am not sure if the Django development
trunck is stable enough to use. I will give it a try.

>
> You don't mention your system type but given the backslashes in the path
> name I'm guessing Windows.  In which case it's likely you are hitting this:
>
> http://code.djangoproject.com/ticket/9212
>
> (Even if you are not running Windows you could hit this if your gettext
> package is earlier than 0.15.  Look at the output of 'xgettext --version' to
> see if this is what you are hitting.  If it's lower than 0.15 then this is
> likely the problem.)
>
> The bug is in xgettext and was fixed in xgettext 0.15.  Unfortunately the
> most-easily installed gettext utilities binaries for Windows are older than
> that.  Therefore we put a fix into Django to work around the xgettext bug,
> but this problem was reported after 1.0 was shipped so you'll have to run
> with a 1.0.X branch or trunk checkout in order to get it.  Alternatively you
> could install a gettext package that is 0.15 level or higher (the one that
> cygwin installs, for example, does not have this problem).
>
> Karen- Hide quoted text -
>
> - Show quoted text -

Karen Tracey

unread,
Oct 14, 2008, 12:10:57 AM10/14/08
to django...@googlegroups.com
On Mon, Oct 13, 2008 at 11:07 PM, Chuck22 <cba...@gmail.com> wrote:

Thanks, Karen. You are correct. My version is Win32 binaries of GNU
gettext-runtime 0.13.1. It seems getting the development trunck is a
better choice for me. But, I am not sure if the Django development
trunck is stable enough to use. I will give it a try.


Trunk is generally quite stable, particularly when some months away from a new release, but if you are worried about trunk stability you could use the 1.0.X release branch instead:

svn co http://code.djangoproject.com/svn/django/branches/releases/1.0.X

That branch only gets bug fixes, no new features, so will have lower risk of instability.  (In fact so far there is not much difference between trunk and that branch, but as development proceeds for 1.1 they will begin to diverge more.)

Karen
Reply all
Reply to author
Forward
0 new messages