Edgewall Software

Opened 13 years ago

Last modified 8 years ago

#517 new defect

i18n filter works on attributes it doesn't need to

Reported by: craig@… Owned by: cmlenz
Priority: minor Milestone: 0.9
Component: Internationalization Version: 0.6
Keywords: i18n Cc:

Description

The i18n filter is currently set to run over the following attributes:

INCLUDE_ATTRS = frozenset([
        'abbr', 'alt', 'label', 'prompt', 'standby', 'summary', 'title'
    ])

The current code in place checks to see if the keys of BaseString? based values are in the set, however ignores this set when there is dynamic content in the value. I have a suggested patch: http://paste.pocoo.org/show/568848/

The two main changes are as follows:

  1. Pay attention to the variable translate_attrs passed into the __call__ function.
  2. Always check to ensure that the attribute name is one that should be worked on regardless of the type of the value. This in our load of

For example the following currently is true:

This would only attempt to translate title. href and rel are ignored. This is correct. <a href="http://www.google.com" title="Hello" rel="external">Googs</a>

If the values are dynamic, href, title and rel are all checked (recursively, even though the i18n filter never does anything with them. <a href="${google_url}" title="Hello" rel="${'external'}">Googs</a>

In this example I am running our web page hit 10 times: http://paste.pocoo.org/show/568849/

Again the more dynamic valued attributes you have the more performance penalty you pay.

I plan to submit a benchmark example that shows this in more detail.

Change History (2)

comment:1 Changed 13 years ago by anonymous

  • Priority changed from major to minor

comment:2 Changed 8 years ago by hodgestar

  • Milestone changed from 0.7 to 0.9

Moved to milestone 0.9.

Note: See TracTickets for help on using tickets.