#5885: simple_tag is not compatible with _() syntax in templates
----------------------------------------------------+-----------------------
Reporter:  Dmitri Fedortchenko <[EMAIL PROTECTED]>  |       Owner:  nobody      
                                                            
  Status:  new                                      |   Component:  Template 
system                                                         
 Version:  SVN                                      |    Keywords:  i18n 
simple_tag translation internationalization templates documentation
   Stage:  Unreviewed                               |   Has_patch:  1           
                                                            
----------------------------------------------------+-----------------------
 Creating a simple_tag decorated tag and then passing it a _('text') does
 not work.

 The error produced is:
 {{{
 Failed lookup for key [_('links')]
 }}}

 Code that produces this error:
 {{{
 @register.simple_tag
 def title(text):
     return text.title()
 }}}

 {{{
 {% title _('links') %}
 }}}

 Trace:
 {{{
 Traceback (most recent call last):
 File "/sw/lib/python2.5/site-packages/django/template/__init__.py" in
 render_node
   813. result = node.render(context)
 File "/sw/lib/python2.5/site-packages/django/template/__init__.py" in
 render
   930. resolved_vars = [var.resolve(context) for var in
 self.vars_to_resolve]
 File "/sw/lib/python2.5/site-packages/django/template/__init__.py" in
 resolve
   707. return self._resolve_lookup(context)
 File "/sw/lib/python2.5/site-packages/django/template/__init__.py" in
 _resolve_lookup
   757. raise VariableDoesNotExist("Failed lookup for key [%s] in %r",
 (bit, current)) # missing attribute
 }}}

 I noticed that the following works:
 {{{
 {{ _('Translate Me')|title }}
 }}}
 However the documentation only mentions that the following syntax is
 possible:
 {{{
 {% some_special_tag _("Page not found") value|yesno:_("yes,no") %}
 }}}

 In any case, I believe that to make the behaviour of the _() syntax more
 consistent, it should work even with simple_tag.
 I realise that my patch may duplicate some code, but it's the best I could
 come up with at the moment.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5885>
Django Code <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
-~----------~----~----~----~------~----~------~--~---

Reply via email to