How one becomes lazy (when one is being translated by Django)

by admin on 17 May 2008

I’ve enjoyed digging even deeper into the lazy text questions that I came up with last time. The “thingamajig” returned by ugettext_lazy indeed waits until unicode is called upon it, then it runs through translation.

You can see this by the way ugettext_lazy is defined. It’s in core/utils/translation/

ugettext_lazy = lazy(ugettext, unicode)

That call to lazy produces a bit of functional programming magic (see core/utils/ for the def lazy) that results in ugettest_lazy calling ugettext (the standard translation function) whenever its unicode value is requested (i.e., every time it’s used as a string.)

Fancy stuff, to my little brain anyway.

Comments on this entry are closed.

Previous post:

Next post: