gettext is not defined - admin site

314 views
Skip to first unread message

ygneo

unread,
Nov 5, 2007, 3:00:57 PM11/5/07
to Django users
I use Django 0.96 in a SuSE with Python 2.3.3.

I'm getting this JavaScript error: "gettext is not defined" when I try
to edit an object with date field in the admin site. I have seen that
occurs when calendar.js is trying to populate the month names in the
correct language. I use language_code = es_ES and default_charset =
utf-8 and i have configurated apache to use utf-8 as default charset.
I also have found with FireBug that really the error is a Django
error:

UnicodeEncodeError at /convenios/admin/jsi18n/
'ascii' codec can't encode character u'\xe9' in
position 23:

For this reason jsi18n doesn't load and i can't use gettext.

Otherwise, in an Ubuntu installation of Django, with same lang code,
and Python 2.5.1, all works fine.

Any idea?

Thanks a lot!

ygneo

unread,
Nov 6, 2007, 12:36:05 PM11/6/07
to Django users
Some advances in my investigation about this error.

The problem seems to be in the characters codification. I don't know
if django or maybe apache are codifying badly the special characteres
in spanish needed for translations. The same error happened when I try
to translate title and branding in templates of the Admin Site. I had
to delete every "trans" from templates y put the text directly,
without possibility of translation. I remenbered that recently and I
decided to do the same in calendar.js and DateTimeShorctus.js, getting
disappear all gettext calls and using directly spanish text for
months, days and Today link.

It's a solution for the application I'm doing, 'cause it doesn't have
to be translated, but I think it's not a good solution, and I'm still
wondering waht is the origin of the problema. Exactly the same app
works fine in the same django version but over Ubuntu 7.04 with python
2.5 instead of SuSE 9.X with python 2.3, where I found the problem.

Any idea about this issue?

(Sorry if my english is not so good)

Malcolm Tredinnick

unread,
Nov 6, 2007, 9:22:52 PM11/6/07
to django...@googlegroups.com

Using non-ASCII characters with Django 0.96 is unfortunately not
completely solid. Sometimes things work, sometimes they don't. It's why
we had to put all the work into making things use unicode internally.
Translations are an area that are particularly vulnerable to problems,
since ASCII strings end up being changed to non-ASCII.

There's a not a lot we can do about this except recommend that you
upgrade to use subversion trunk (which will require a bit of porting of
your code). I realise that might not be the easiest solution, but, as I
said, it wasn't possible to fix all the problems without a major change,
so at some point we had to make that change.

Regards,
Malcolm

--
The sooner you fall behind, the more time you'll have to catch up.
http://www.pointy-stick.com/blog/

Reply all
Reply to author
Forward
0 new messages