#4539: translation.ugettext loses variable content from blocktrans
------------------------------------------+---------------------------------
   Reporter:  [EMAIL PROTECTED]  |                Owner:  nobody              
     Status:  new                         |            Component:  
Internationalization
    Version:  SVN                         |           Resolution:               
       
   Keywords:  blocktrans                  |                Stage:  Accepted     
       
  Has_patch:  1                           |           Needs_docs:  0            
       
Needs_tests:  0                           |   Needs_better_patch:  0            
       
------------------------------------------+---------------------------------
Comment (by [EMAIL PROTECTED]):

 Replying to [comment:4 mtredinnick]:
 > This doesn't look like the right solution. context.push() doesn't clean
 out the context; it only adds a marker, in effect, so that we can remove
 (pop) any new content added since that point. The existing content is
 still accessible.
 >
 > So this patch doesn't look like it's getting to the heart of the
 problem, which is why the variables are resolving to blank in the first
 place if they exist in the context.
 Look at the example:
 first is created context for loop:
 [{spell: {spell: 'spell', wave: 'wave', target: 'target', caster: 'caster'
 count: 'count'}}
 then we move into blocktrans and try to resolve variable:
  * spell.count is resolved as count and pushed to the context
  * spell.caster is resolved as caster and pushed to the context
  * spell.spell is resolved as 'spell' and pushed to the context
  * this is crucial point - from now spell.* takes resolution from wrong
 (new) context level, so:
  * spell.target is wrong (spell.spell.target doesn't exist) and results to
 ''
  * spell.wave is wrong (spell.spell.wave doesn't exist) and results to''
 
 context corresponding to these step is as follows:
 
  * [{u'count': u'count'}, {'forloop': {'parentloop': {}, 'last': True,
 'counter': 1, 'revcounter0': 0, 'revcounter': 1, 'counter0': 0, 'first':
 True}, u'spell': {'count': 'count', 'caster': 'caster', 'spell': 'spell',
 'target': 'target', 'wave': 'wave'}}, {'spells': [{'count': 'count',
 'caster': 'caster', 'spell': 'spell', 'target': 'target', 'wave':
 'wave'}]}]
  * [{u'count': u'count', u'caster': u'caster'}, {'forloop': {'parentloop':
 {}, 'last': True, 'counter': 1, 'revcounter0': 0, 'revcounter': 1,
 'counter0': 0, 'first': True}, u'spell': {'count': 'count', 'caster':
 'caster', 'spell': 'spell', 'target': 'target', 'wave': 'wave'}},
 {'spells': [{'count': 'count', 'caster': 'caster', 'spell': 'spell',
 'target': 'target', 'wave': 'wave'}]}]
  * [{u'count': u'count', u'caster': u'caster', u'spell': u'spell'},
 {'forloop': {'parentloop': {}, 'last': True, 'counter': 1, 'revcounter0':
 0, 'revcounter': 1, 'counter0': 0, 'first': True}, u'spell': {'count':
 'count', 'caster': 'caster', 'spell': 'spell', 'target': 'target', 'wave':
 'wave'}}, {'spells': [{'count': 'count', 'caster': 'caster', 'spell':
 'spell', 'target': 'target', 'wave': 'wave'}]}]
  * [{u'count': u'count', u'caster': u'caster', u'spell': u'spell',
 u'target': ''}, {'forloop': {'parentloop': {}, 'last': True, 'counter': 1,
 'revcounter0': 0, 'revcounter': 1, 'counter0': 0, 'first': True},
 u'spell': {'count': 'count', 'caster': 'caster', 'spell': 'spell',
 'target': 'target', 'wave': 'wave'}}, {'spells': [{'count': 'count',
 'caster': 'caster', 'spell': 'spell', 'target': 'target', 'wave':
 'wave'}]}]
  * [{u'count': u'count', u'caster': u'caster', u'spell': u'spell',
 u'target': '', u'wave': ''}, {'forloop': {'parentloop': {}, 'last': True,
 'counter': 1, 'revcounter0': 0, 'revcounter': 1, 'counter0': 0, 'first':
 True}, u'spell': {'count': 'count', 'caster': 'caster', 'spell': 'spell',
 'target': 'target', 'wave': 'wave'}}, {'spells': [{'count': 'count',
 'caster': 'caster', 'spell': 'spell', 'target': 'target', 'wave':
 'wave'}]}]
 
 If ''context[0]'' doesn't exist during computation of new context level,
 everything goes ok. So I still think, that my patch is correct solution.
 We cannot resolve variable from context which is unde generation. We have
 to use upper levels (so context[1] and upper levels). So I still think,
 that my patch is correct solution.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/4539#comment:5>
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