As I said initially when we discussed this on IRC, I believe a "i18n_url" is good enough
and would fit well with the other i18n related template tags.
Besides the ambiguity of a potential keyword argument "lang", I'd like to mention that
we specifically chose to use "i18n_patterns" as the name for the function that returns
i18n-enabled URL patterns to be explicit about when a URL should be translated. I believe
this pattern should also be applied to the template tag which a user might use to point to
one of those translatable URLs.
Jannis
On Sat, Jun 25, 2011 at 2:50 AM, maxk <klym...@gmail.com> wrote:
> What do you think about something like below
>
> {% url viewname k1=v1, k2=v2 with lang=lang %}
Briefly discussed this via IRC th Jannis. I'm +1 on keeping the new tag
in the i18 ttag lib for the reasons exposed by Jannis. So a prefix like
'i18n_' would fit well IMHO. +1 on this.
Adding that functionality to the i18n tag can also work, I think.
Especially now that Jannis makes me see it wouldn't cause loading of the
i18n machinery for people with USE_i18N=False. But I'd like to
completely avoid the possibility of clashing with existing 'lang'
arguments and I'm not 100% convinced by the "with lang='xx'" part of the
proposed syntax. It is a hybrid between our 'old' "with var as alias"
and the new (from future) "var=alias" form. I'm -0 on this option
--
Ramiro Morales
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
>
> On Monday, July 4, 2011 1:42:37 AM UTC+12, brocaar wrote:
> What about not implementing this as a url tag but as a translation-
> override tag? Then it is not only possible to specify the language to
> use for your URL translation, but as well for other translatable
> content. Example:
>
> {% transoverride language_code %}
> {% trans "Register account" %}: {% url account:register %}
> {% endtransoverride %}
Oh, I like that much better, too.
> That does have the advantage of being more flexible even in just the context of urls. For example, referring to a url via {{ obj.get_absolute_url }}.
> +1 for more flexibility.
>
> That's one ugly tag name though :D
Agreed, what about just "language", e.g.:
{% language lang_code %}
{% trans "Register account" %}: {% url account:register %}
{% endlanguage %}
Jannis
Agreed, what about just "language", e.g.:
{% language lang_code %}
{% trans "Register account" %}: {% url account:register %}
{% endlanguage %}
Sam
> --
> You received this message because you are subscribed to the Google Groups "Django developers" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/huy6SEXMIBkJ.
Great, thanks all for your opinions, I actually went ahead yesterday
and added it in https://code.djangoproject.com/changeset/16501
Jannis
Isn't this about more than language, but also locale?
In Grantlee I implemented this as a with_locale tag:
And then eg dates are also localized:
http://steveire.files.wordpress.com/2010/11/contacts_multi_lang_headers.png