Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 5, 2005 16:24:13

o.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


Hello,

While gettext is in the PATH, I get the following javascript errors
browsing an admin page with calendar and DateTime widgets:

Erreur : gettext is not defined
Fichier source :http://127.0.0.1:8000/media/js/calendar.jsLigne : 26

Erreur : gettext is not defined
Fichier source :http://127.0.0.1:8000/media/js/admin/DateTimeShortcuts.jsLigne : 114

Is it a bug or do I need to set something somewhere ?

I use FireFox 1.5 or IE 6 under Win2k.

Olivier.

Offline

#2 Dec. 5, 2005 16:31:36

h.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


>While gettext is in the PATH, I get the following javascript errors
>browsing an admin page with calendar and DateTime widgets:

JavaScript doesn't have anything to do with PATH ;-)

You need to check what is in the pages - if you for example overloaded
admin templates with your own, you will need to add the link tag for
the /admin/jsi18n/ url - that's the JavaScript library that is loaded
for admin pages that need translations.

bye, Georg

Offline

#3 Dec. 5, 2005 16:45:07

o.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


Georg,

I did not overload any admin template.

The problem appears the last time calendar.js and DateTimeShortcuts.js
have been updated by svn up.

Do I need to add a parameter in the corresponding model meta.Admin ?

Olivier.

Offline

#4 Dec. 5, 2005 18:42:13

h.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


>The problem appears the last time calendar.js and DateTimeShortcuts.js
>have been updated by svn up.

Not reproduceable here - have you removed your .pyc files after svn up?
svn doesn't update .pyc files, and since .pyc are created based on the
date/time of the .py file, sometimes old modules stick around.

The problem is that your code doesn't load the JavaScript translation l
ibraries - check the source of the HTML pages wether there is a
reference to the script library in there and wether the path is
correct. And if the path looks ok, try to load that URL directly in the
browser to check wether you get any error when accessing it.

bye, Georg

Offline

#5 Dec. 6, 2005 18:32:45

o.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


>have you removed your .pyc files after svn up?

yes

>heck the source of the HTML pages wether there is a reference to the script
>library in there and wether the path is correct

The looks strange:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; lang="fr" xml:lang="fr">
<head>
<title>Change event | Site d'administration de Django</title>
<link rel="stylesheet" type="text/css" href="/media/css/base.css" />

<script type="text/javascript" src="../../../jsi18n/"></script>
<script type="text/javascript" src="/media/js/core.js"></script><script
type="text/javascript"
src="/media/js/admin/RelatedObjectLookups.js"></script><script
type="text/javascript" src="/media/js/calendar.js"></script><script
type="text/javascript"
src="/media/js/admin/DateTimeShortcuts.js"></script><script
type="text/javascript"
src="/media/js/tiny_mce/tiny_mce.js"></script><script
type="text/javascript" src="/media/js/tiny_mce/textareas.js"></script>
</head>
...

Olivier.

Offline

#6 Dec. 6, 2005 18:56:53

h.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


There is nothing strange in there, it's mostly as expected.

<script type="text/javascript" src="../../../jsi18n/"></script>

This line is what pulls in the JS translation library. Check the URL
where the problem is, apply the relative URL to that to reach the real
URL for the lib and try it directly in your browser and see what it
produces.

bye, Georg

Offline

#7 Dec. 6, 2005 19:25:04

o.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


Request Method: GET
Request URL:http://127.0.0.1:8000/admin/jsi18n/Exception Type: KeyError
Exception Value: ''
Exception Location: C:\soft\django_src\django\views\i18n.py in
javascript_catalog, line 156
Traceback (innermost last)

C:\soft\django_src\django\core\handlers\base.py in get_response
73. response = callback(request, *callback_args, **callback_kwargs)

C:\soft\django_src\django\views\i18n.py in javascript_catalog
156. # for l in t.split('\n'):

Offline

#8 Dec. 6, 2005 20:18:44

h.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


>Exception Type: KeyError
>Exception Value: ''
>Exception Location: C:\soft\django_src\django\views\i18n.py in
>javascript_catalog, line 156

Outch. That's a broken translation catalog - the '' entry in .po/.mo
files is important, it's the metadata stuff. If you click the
disclosure triangle on the line of error (156) in the traceback, you
will be able to see local variables. What is the value of the local
variable "t"? This should be a dictionary with translations, if it
isn't, something is really weird.

The '' entry includes the Plural-Forms option, that's why I look for it
- I need to translate that into something for JavaScript. I do handle
the non-existence of that option, but not the complete absence of the
'' entry.

What's happening in that code: it is first taking the
settings.LANGUAGE_CODE language and pulls the djangojs translation
catalog for that. After that it tries the request.LANGUAGE_CODE, if
that is different from the settings, and merges those translations into
the big catalog.

So what could happen here is that you have set your default language to
some language that doesn't yet support djangojs translations (not all
languages already include the translations) and maybe you are using the
same language in your browser or don't have the LocaleMiddleware
installed.

To verify this, it would be interesting if you could switch your system
to english to see what happens. If it really is what I suppose it is,
it's easy to fix for me - just want to make sure that it's really that
problem on your side.

bye, Georg

Offline

#9 Dec. 6, 2005 20:23:52

o.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


Bingo!

There is no problem with en, but with fr ...

Olivier.

Offline

#10 Dec. 6, 2005 20:32:02

h.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gettext is not defined


>Bingo!
>There is no problem with en, but with fr ...

Yep, fr still has no djangojs.po. Ok, I committed a patch, please svn
up and try wether that solves your problem. It should give you now
english strings in the javascript code (as fr still has no
djangojs.po), but at least the error should be gone.

bye, Georg

Offline

Board footer

Moderator control

Enjoy the 20th of January
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support