I’ve really messed up with stuff like
<p>{% trans "Visit our" %}<a href="{% url "help" %}">{% trans "help page" %}</a>
Where xurl is my tag registered like
@register.simple_tag(takes_context=True)
def xurl(context, view_name, *args, **kwargs):
As I know I can use variables in {% blocktrans %}, so good solution for me is somehow use my tag like django’s url tag like
{% xurl "help" as help_url %}
and then use help_url variable in blocktrans. I can’t use @register.tag to use “as” because I need to get current language from context.
“Django 1.4 gained the ability to look for a language prefix in the URL pattern when using the new i18n_patterns() helper function. Additionally, it’s now possible to define translatable URL patterns using ugettext_lazy(). See Internationalization: in URL patterns for more information about the language prefix and how to internationalize URL patterns.”
https://docs.djangoproject.com/en/dev/topics/i18n/translation/#url-internationalization