Edgewall Software

Ticket #541 (closed defect: fixed)

Opened 2 years ago

Last modified 17 months ago

i18n directive interferes with py:if expression

Reported by: hoff.st@… Owned by: hodgestar
Priority: minor Milestone: 0.7
Component: Template processing Version: 0.6
Keywords: i18n Cc:

Description

I want to exclude a 'span' HTML element, if value=0. This is the minimized template markup for this use case:

<label i18n:msg="timedelta">
  Duration:
  <input type="text" name="input"
         value="$value" />
  seconds
  <span py:if="value">
    (${fmt_value(value)})
  </span>
</label>

I've added the i18n directive to get a msgid like

'Duration: [1:] seconds [2:](%(timedelta)s[3:]'

instead of split msgids 'Duration:', 'seconds', ...).

But with value=0 the py:if directive seems ineffective:

<label>Duration:
  <input type="text" name="input" value="0" />
  seconds
  <span>
    ()
  </span></label>

The 'span' element is included regardless of the value of 'value'.

Simply removing the i18n directive like

<label>
  Duration:
  <input type="text" name="input"
         value="$value" />
  seconds
  <span py:if="value">
    (${fmt_value(value)})
  </span>
</label>

fixes this:

<label>Duration:
  <input type="text" name="input" value="0" />
  seconds
</label>

'span' disappears correctly, if value=0. If not for the braces I wouldn't have noticed this nor would I care.

Maybe there is a related issue in the Internationalization domain: When the py:if directive would strip the 'span' element successfully, the expression i18n:msg="timedelta" would become invalid. Not sure, if that would hurt on template rendering time.

Attachments

Change History

Changed 2 years ago by hodgestar

  • owner changed from cmlenz to hodgestar

Are you using the latest 0.6.x version from svn or the 0.6.0 release? If you're not using the latest 0.6.x could you try that? I think some related bugs were fixed in svn awhile ago.

Changed 2 years ago by hoff.st@…

I've been using Trac dependencies for most of my test environments, so this should be equal to genshi-0.6 release as I guess.

Thanks for the hint on fixes in 0.6.x. I'll have to setup another test environment with focus on latest Genshi code. Hope to report my findings soon.

Changed 17 months ago by hodgestar

  • status changed from new to closed
  • resolution set to fixed

Since 0.6.1 has been released with the fixes I mentioned I'm closing this for now. Please re-open in necessary.

Add/Change #541 (i18n directive interferes with py:if expression)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.