So basically, it's like the difference between range() and xrange().
Thanks Niels, that helped a lot.

On Apr 12, 3:42 pm, "Niels" <[EMAIL PROTECTED]> wrote:
> Your understanding is basically correct. Gettext_lazy returns an
> object that will be stored inside the form class definition. The
> actual translation then occurs when that object is evaluated as a
> string. And there is quite some magic going on behind the scenes:
>
> >>> from django.utils.translation import gettext_lazy as _
> >>> lazystr = _("Home")
> >>> lazystr.__class__
>
> <class django.utils.functional.__proxy__ at 0x0139E480>>>> lazystr.__promise__
>
> <bound method __proxy__.__promise__ of 'Home'>>>> lazystr._proxy____func
>
> <function gettext at 0x013511B0>>>> lazystr._proxy____func.__module__
>
> 'django.utils.translation'
>
> >>> lazystr._proxy____args
> ('Home',)
> >>> from django.utils.translation import activate
> >>> activate('fr')
> >>> str(lazystr)
> 'Accueil'
> >>> activate('en')
> >>> str(lazystr)
> 'Home'
>
> On Apr 12, 7:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > That worked, thanks very much.  I'm not quite clear on the difference
> > between gettext and gettext_lazy however.  As I understand it, gettext
> > will translate the string when the Python file is loaded (imported)
> > and gettext_lazy will translate the string when the template is
> > rendered.  Is that it?
>
> > Vincent.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to