Hi all!

Currently, for adding an url to a blocktrans, we need:

{% url "home" as home %}
{% blocktrans with the_url=home %}
...
{% endblocktrans %}

(https://docs.djangoproject.com/en/dev/topics/i18n/translation/#blocktrans-template-tag)

However, this is not equivalent to use {% url "home" %} without the 
blocktrans because {% url "home" as home %} fails silently if url "home" 
doesn't exist. I believe this was added as part of fixing 
#7239<https://code.djangoproject.com/ticket/7239>
.

It seems there is no way to add urls to {% blocktrans %} without forcing 
them to fail silently. IMO this is a problem since most cases the user 
wants an error when the link does not exist, as per {% url "home" %}.

I believe the only current solution is to reverse the url in the view and 
pass it as a context variable, something that is against the whole idea of 
{% url %}, and is not compatible with urls in a {% blocktrans %} inside a 
{% for %} loop.


I wonder if it is worth considering the keyword "url" to blocktrans, which 
would be used to reverse the argument of the variable after it, as

{% blocktrans url the_url="home" %}
<a href="{{the_url}}">home</a>
{% blocktrans %}

The problem seems to be the arguments, which we could solve with a keyword 
"arg"

{% blocktrans url the_url="home" arg arg1=A %}

as in {% url %}. However, I'm not fully aware of the potential problems 
this brings, why I'm asking for help. Some points I consider debatable:

1. we need 2 new keywords for fixing this, "url" and "arg".
2. on one hand, "arg" could be used more generically in the future, but on 
the other hand it has also the potential to add logic to the template 
system.

Are there stronger reasons for not considering this?

Thanks,
Jorge


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/83d6f72c-5dfa-4591-bbb4-34fc53fdfdaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to