本文整理汇总了Python中zope.formlib.i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _toFieldValue
def _toFieldValue(self, input):
value = super(Bytes, self)._toFieldValue(input)
if type(value) is unicode:
try:
value = value.encode('ascii')
except UnicodeError, v:
raise ConversionError(_("Invalid textual data"), v)
示例2: addButtonLabel
def addButtonLabel(self):
button_label = _('Add %s')
button_label = translate(button_label, context=self.request,
default=button_label)
title = self.context.title or self.context.__name__
title = translate(title, context=self.request, default=title)
return button_label % title
示例3: _toFieldValue
def _toFieldValue(self, input):
if input:
try:
return self.convertTokensToValues([input])[0]
except (InvalidValue, TypeError) as e:
raise ConversionError(_("Invalid value"), e)
else:
return self.context.missing_value
示例4: _toFieldValue
def _toFieldValue(self, input):
if input == self._missing:
return self.context.missing_value
else:
try:
return int(input)
except ValueError as v:
raise ConversionError(_("Invalid integer data"), v)
示例5: _toFieldValue
def _toFieldValue(self, input):
"""See SimpleInputWidget"""
if input is None:
input = []
elif not isinstance(input, list):
input = [input]
try:
values = self.convertTokensToValues(input)
except InvalidValue, e:
raise ConversionError(_("Invalid value"), e)
示例6: BooleanRadioWidget
def BooleanRadioWidget(field, request, true=_('on'), false=_('off')):
vocabulary = SimpleVocabulary.fromItems( ((true, True), (false, False)) )
widget = RadioWidget(field, vocabulary, request)
widget.required = False
return widget
示例7: BooleanSelectWidget
def BooleanSelectWidget(field, request, true=_('on'), false=_('off')):
vocabulary = SimpleVocabulary.fromItems( ((true, True), (false, False)) )
widget = SelectWidget(field, vocabulary, request)
widget.size = 2
widget.required = False
return widget
def BooleanDropdownWidget(field, request, true=_('on'), false=_('off')):
vocabulary = SimpleVocabulary.fromItems( ((true, True), (false, False)) )
widget = DropdownWidget(field, vocabulary, request)
widget.required = False
return widget
_msg_true = _("True")
_msg_false = _("False")
class BooleanDisplayWidget(DisplayWidget):
def __call__(self):
if self._renderedValueSet():
value = self._data
else:
value = self.context.default
if value:
return _msg_true
else:
return _msg_false