#14801: Support for string methods with lazy translations
-------------------------------------------+--------------------------------
Reporter: bronger | Owner: nobody
Status: closed | Milestone:
Component: Internationalization | Version: 1.2
Resolution: wontfix | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bronger):
Actually it's about applying transformations to a lazy object rather than
gettext. I solve this problem currently like this:
{{{
def format_lazy(string, *args, **kwargs):
return string.format(*args, **kwargs)
format_lazy = allow_lazy(format_lazy, unicode)
}}}
(BTW, it would be nice if you could use {{{allow_lazy}}} as a Python
decorator.)
and then in models.py:
{{{
class Meta:
verbose_name = format_lazy(_(u"Raman {apparatus_number}
measurement"), apparatus_number=1)
}}}
I found {{{allow_lazy}}} after I had wrote this issue report, which turns
it into an enhancement request because I'd still prefer
{{{
class Meta:
verbose_name = _(u"Raman {apparatus_number}
measurement").format(apparatus_number=1)
}}}
i.e., if the lazy strings would implement some of the string methods.
--
Ticket URL: <http://code.djangoproject.com/ticket/14801#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.