Is there an easy solution to mark string parameters of an inclusion_tag (or a templatetag in general) for translation? In this example i want to mark the second parameter for translation:
{% render_tile_section qs "Foo" %}
Using a inclusion_tag like this obviously doesn’t work:
from django.utils.translation import ugettext_lazy as _
@register.inclusion_tag('content/includes/tile_section.html')
def render_tile_section(qs, headline=''):
return {'qs': qs,
'headline': u'%s' % _(headline) if headline else ''}
My first idea was to subclass inclusion_tag and make it work like the trans tag for string parameters. But as far as i know Django’s makemessages command will only evaluate trans and blocktrans in templates or i there a way to extend it? Any other ideas?
The functionality is already built into Django’s templatetags. Totally missed this in the docs: