As mentioned in this section of Translation | Django documentation, the function ugettext_noop is a utility function for internationalization:
ugettext_noop(message) ¶
Marks strings for translation but doesn’t translate them now. This can be used to store strings in global variables that should stay in the base language (because they might be used externally) and will be translated later.
Also, this answer provides an example of its usage:
import logging
from django.http import HttpResponse
from django.utils.translation import ugettext as _, ugettext_noop as _noop
def view(request):
msg = _noop("An error has occurred")
logging.error(msg)
return HttpResponse(_(msg))
Despite these docs, I still don't understand why should I mark a string as extractable for translation. To me it seems that ugettext_noop
is nothing but a reminder, and even so, what's the purpose of reminding programmers that some strings (msg
in this case) are to be translated later?