[Django] #24517: makemessages doesn't recognize aliased gettext functions

34 views
Skip to first unread message

Django

unread,
Mar 20, 2015, 5:04:59 PM3/20/15
to django-...@googlegroups.com
#24517: makemessages doesn't recognize aliased gettext functions
-------------------------------------+-------------------------------------
Reporter: Mezgrman | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.7
Internationalization | Keywords: makemessages, i18n,
Severity: Normal | translation, l10n
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24517>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2015, 5:12:28 PM3/20/15
to django-...@googlegroups.com
#24517: makemessages doesn't recognize aliased gettext functions
-------------------------------------+-------------------------------------
Reporter: Mezgrman | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.7
Internationalization | Resolution:
Severity: Normal | worksforme
Keywords: makemessages, i18n, | Triage Stage:
translation, l10n | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24517#comment:1>

Reply all
Reply to author
Forward
0 new messages