Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #900 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

Support between gettext (i18n) and validators.

Reported by: Drejer Owned by: max
Priority: normal Milestone: 0.9
Component: TurboGears Version: 0.9a6
Severity: normal Keywords:


I would like to mention, that i am NOT using the svn version, why this may allready have been corrected. If so feel fre to delete my post.

When converting text through the gettext system, a lazystring object is returned. This object imitates a string for all of its normal functions, but does however lack the implementation of comparing operators (eq). For this reason translated text cannot be used by validators. If attempted the validator will try to compare a Unicode string (incomming data) with a lazystring (translated data), which doesnt work since the eq function isn't present. The use for translated text in validators is rellevant in cases, where a check for submit buttons is required. Since the text is translated the validator might look like the following:

@validate(validators={'action': validators.OneOf?([_('copy'), _('move'), _('cancel')])})

A fix for this is to to add the following snippet to the lazystring class in turbogears/i18n/tg_gettext around line 104:

    def __eq__(self, other):
        return other==self.eval()

Change History

comment:1 Changed 13 years ago by max

  • Status changed from new to assigned
  • Owner changed from anonymous to max

comment:2 Changed 13 years ago by max

  • Status changed from assigned to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.