Opened 10 years ago
Closed 10 years ago
#24517 closed Bug (worksforme)
makemessages doesn't recognize aliased gettext functions
Reported by: | Julian Metzler | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 1.7 |
Severity: | Normal | Keywords: | makemessages, i18n, translation, l10n |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When running manage.py makemessages
, translation functions like ugettext_lazy
are ignored when they are imported with a name other than their original name or _
.
This will work as expected:
from django.utils.translation import ugettext_lazy my_string = ugettext_lazy("This will be recognized.")
This will also work:
from django.utils.translation import ugettext_lazy as _ my_string = _("This will also be recognized.")
But this will not:
from django.utils.translation import ugettext_lazy as lazy_ my_string = lazy_("This will not be recognized.")
This wouldn't be too much of a problem in many cases, but if you need to use more than one translation function in your code, this WILL be a problem.
Note:
See TracTickets
for help on using tickets.
That's the expected behavior. If you need several translation functions, use their full name in the code. And in the case you'd *really* need another function name, you have the possibility of creating a custom makemessages command and override the
xgettext_options
class attribute (new in 1.7) to include some more--keyword
xgettext options.