0

When doing i18n support for django apps it sometimes comes up to have to use ugettext and ugettext_noop in the same file. It's a common convention to import ugettext as _ which is a nice convention in code. I'm wondering if there is such a convention for ugettext_noop? Maybe __?

I'm envisioning something like this:

from django.utils.translation import ugettext as _, ugettext_noop as ?

MY_CONSTANT = ?('translate me later')

def my_function():
    return _('translate me now')

Fill in the ?.

Cory
  • 22,772
  • 19
  • 94
  • 91
  • Import it like it is without convention: `from django.utils.translation import ugettext_noop` – Mounir May 20 '13 at 21:29

1 Answers1

4

Based on the answer answer ugettext and ugettext_lazy functions not recognized by makemessages in Python Django the short answer is:

  • you could alias ugettext_noop to something else, but gettext won't recognize if alias is not one of the gettext keyword aliases.

Summary: only one short alias (_) can be used, for other gettext functions you should not use aliases.

Community
  • 1
  • 1
Robert Lujo
  • 15,383
  • 5
  • 56
  • 73