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/__init__.py:
core/utils/translation/__init__.py
ugettext_lazy = lazy(ugettext, unicode)
That call to lazy
produces a bit of functional programming magic (see core/utils/functional.py 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.