Changeset 6642
- Timestamp:
- 11/03/07 21:08:02 (1 year ago)
- Files:
-
- django/trunk/django/newforms/fields.py (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/newforms/fields.py
r6625 r6642 17 17 from sets import Set as set 18 18 19 from django.utils.translation import ugettext_lazy 19 from django.utils.translation import ugettext_lazy as _ 20 20 from django.utils.encoding import StrAndUnicode, smart_unicode 21 21 … … 43 43 hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden". 44 44 default_error_messages = { 45 'required': ugettext_lazy(u'This field is required.'),46 'invalid': ugettext_lazy(u'Enter a valid value.'),45 'required': _(u'This field is required.'), 46 'invalid': _(u'Enter a valid value.'), 47 47 } 48 48 … … 88 88 def _build_error_messages(self, extra_error_messages): 89 89 error_messages = {} 90 90 91 def get_default_error_messages(klass): 91 92 for base_class in klass.__bases__: … … 93 94 if hasattr(klass, 'default_error_messages'): 94 95 error_messages.update(klass.default_error_messages) 96 95 97 get_default_error_messages(self.__class__) 96 98 if extra_error_messages: … … 125 127 class CharField(Field): 126 128 default_error_messages = { 127 'max_length': ugettext_lazy(u'Ensure this value has at most %(max)d characters (it has %(length)d).'),128 'min_length': ugettext_lazy(u'Ensure this value has at least %(min)d characters (it has %(length)d).'),129 'max_length': _(u'Ensure this value has at most %(max)d characters (it has %(length)d).'), 130 'min_length': _(u'Ensure this value has at least %(min)d characters (it has %(length)d).'), 129 131 } 130 132 … … 153 155 class IntegerField(Field): 154 156 default_error_messages = { 155 'invalid': ugettext_lazy(u'Enter a whole number.'),156 'max_value': ugettext_lazy(u'Ensure this value is less than or equal to %s.'),157 'min_value': ugettext_lazy(u'Ensure this value is greater than or equal to %s.'),157 'invalid': _(u'Enter a whole number.'), 158 'max_value': _(u'Ensure this value is less than or equal to %s.'), 159 'min_value': _(u'Ensure this value is greater than or equal to %s.'), 158 160 } 159 161 … … 182 184 class FloatField(Field): 183 185 default_error_messages = { 184 'invalid': ugettext_lazy(u'Enter a number.'),185 'max_value': ugettext_lazy(u'Ensure this value is less than or equal to %s.'),186 'min_value': ugettext_lazy(u'Ensure this value is greater than or equal to %s.'),186 'invalid': _(u'Enter a number.'), 187 'max_value': _(u'Ensure this value is less than or equal to %s.'), 188 'min_value': _(u'Ensure this value is greater than or equal to %s.'), 187 189 } 188 190 … … 211 213 class DecimalField(Field): 212 214 default_error_messages = { 213 'invalid': ugettext_lazy(u'Enter a number.'),214 'max_value': ugettext_lazy(u'Ensure this value is less than or equal to %s.'),215 'min_value': ugettext_lazy(u'Ensure this value is greater than or equal to %s.'),216 'max_digits': ugettext_lazy('Ensure that there are no more than %s digits in total.'),217 'max_decimal_places': ugettext_lazy('Ensure that there are no more than %s decimal places.'),218 'max_whole_digits': ugettext_lazy('Ensure that there are no more than %s digits before the decimal point.')215 'invalid': _(u'Enter a number.'), 216 'max_value': _(u'Ensure this value is less than or equal to %s.'), 217 'min_value': _(u'Ensure this value is greater than or equal to %s.'), 218 'max_digits': _('Ensure that there are no more than %s digits in total.'), 219 'max_decimal_places': _('Ensure that there are no more than %s decimal places.'), 220 'max_whole_digits': _('Ensure that there are no more than %s digits before the decimal point.') 219 221 } 220 222 … … 264 266 class DateField(Field): 265 267 default_error_messages = { 266 'invalid': ugettext_lazy(u'Enter a valid date.'),268 'invalid': _(u'Enter a valid date.'), 267 269 } 268 270 … … 297 299 class TimeField(Field): 298 300 default_error_messages = { 299 'invalid': ugettext_lazy(u'Enter a valid time.')301 'invalid': _(u'Enter a valid time.') 300 302 } 301 303 … … 336 338 widget = DateTimeInput 337 339 default_error_messages = { 338 'invalid': ugettext_lazy(u'Enter a valid date/time.'),340 'invalid': _(u'Enter a valid date/time.'), 339 341 } 340 342 … … 404 406 class EmailField(RegexField): 405 407 default_error_messages = { 406 'invalid': ugettext_lazy(u'Enter a valid e-mail address.'),408 'invalid': _(u'Enter a valid e-mail address.'), 407 409 } 408 410 … … 434 436 widget = FileInput 435 437 default_error_messages = { 436 'invalid': ugettext_lazy(u"No file was submitted. Check the encoding type on the form."),437 'missing': ugettext_lazy(u"No file was submitted."),438 'empty': ugettext_lazy(u"The submitted file is empty."),438 'invalid': _(u"No file was submitted. Check the encoding type on the form."), 439 'missing': _(u"No file was submitted."), 440 'empty': _(u"The submitted file is empty."), 439 441 } 440 442 … … 458 460 class ImageField(FileField): 459 461 default_error_messages = { 460 'invalid_image': ugettext_lazy(u"Upload a valid image. The file you uploaded was either not an image or a corrupted image."),462 'invalid_image': _(u"Upload a valid image. The file you uploaded was either not an image or a corrupted image."), 461 463 } 462 464 … … 494 496 class URLField(RegexField): 495 497 default_error_messages = { 496 'invalid': ugettext_lazy(u'Enter a valid URL.'),497 'invalid_link': ugettext_lazy(u'This URL appears to be a broken link.'),498 'invalid': _(u'Enter a valid URL.'), 499 'invalid_link': _(u'This URL appears to be a broken link.'), 498 500 } 499 501 … … 556 558 widget = Select 557 559 default_error_messages = { 558 'invalid_choice': ugettext_lazy(u'Select a valid choice. That choice is not one of the available choices.'),560 'invalid_choice': _(u'Select a valid choice. That choice is not one of the available choices.'), 559 561 } 560 562 … … 595 597 widget = SelectMultiple 596 598 default_error_messages = { 597 'invalid_choice': ugettext_lazy(u'Select a valid choice. %(value)s is not one of the available choices.'),598 'invalid_list': ugettext_lazy(u'Enter a list of values.'),599 'invalid_choice': _(u'Select a valid choice. %(value)s is not one of the available choices.'), 600 'invalid_list': _(u'Enter a list of values.'), 599 601 } 600 602 … … 658 660 """ 659 661 default_error_messages = { 660 'invalid': ugettext_lazy(u'Enter a list of values.'),662 'invalid': _(u'Enter a list of values.'), 661 663 } 662 664 … … 720 722 class SplitDateTimeField(MultiValueField): 721 723 default_error_messages = { 722 'invalid_date': ugettext_lazy(u'Enter a valid date.'),723 'invalid_time': ugettext_lazy(u'Enter a valid time.'),724 'invalid_date': _(u'Enter a valid date.'), 725 'invalid_time': _(u'Enter a valid time.'), 724 726 } 725 727 … … 749 751 class IPAddressField(RegexField): 750 752 default_error_messages = { 751 'invalid': ugettext_lazy(u'Enter a valid IPv4 address.'),753 'invalid': _(u'Enter a valid IPv4 address.'), 752 754 } 753 755
