#900: Support between gettext (i18n) and validators.
------------------------+---------------------------------------------------
Reporter: Drejer | Owner: anonymous
Type: defect | Status: new
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()
}}}
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/900>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" 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/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---