There's little practical usage for this in Django. It's something that
was copied over from the standard gettext API. Because there's nothing
equivalent to gettext_lazy in C (or Javascript, see below), you need to
use gettext_noop in situations like this:
msgs = [
gettext_noop('hello'),
gettext_noop('goodbye')
]
def foo(...):
print gettext(msgs[index])
When foo() is called, the msgs[index] entry will be translated using the
currently active locale. That's all well and good, but you have to let
the string-extraction tools (xgettext, or make-messages.py in Django's
parlance) know that the strings inside the msgs lists need to pulled out
for translators. So gettext_noop is used to mark the strings: xgettext
knows to look for things wrapped in gettext_noop and pull then out.
Other than that, it does nothing (it's a no-op function).
This only place where you might this inside Django is in Javascript
files, if you're building up a list of messages that are later going to
be run through gettext() before printing. Note that it's important to
only run the strings through gettext() at the time of output, because at
the time you're creating/compiling the file, you don't know what the
currently active locale is. So you might have an array of Javascript
strings that are canned responsed or something. Marking them with
gettext_noop means that make-messages.py knows to pull them into the PO
file.
I hope that makes things a bit clearer.
Regards,
Malcolm
--
For every action there is an equal and opposite criticism.
http://www.pointy-stick.com/blog/