Commits

crast  committed e25714a

ext: use translation hooks for validation errors. Refs #32.

  • Participants
  • Parent commits 563a62d

Comments (0)

Files changed (2)

File wtforms/ext/django/fields.py

                 if self.data == obj:
                     break
             else:
-                raise ValidationError('Not a valid choice')
+                raise ValidationError(self.gettext('Not a valid choice'))
 
 
 class ModelSelectField(QuerySetSelectField):

File wtforms/ext/sqlalchemy/fields.py

                 if self.data == obj:
                     break
             else:
-                raise ValidationError('Not a valid choice')
+                raise ValidationError(self.gettext(u'Not a valid choice'))
 
 
 class QuerySelectMultipleField(QuerySelectField):
 
     def pre_validate(self, form):
         if self._invalid_formdata:
-            raise ValidationError('Not a valid choice')
+            raise ValidationError(self.gettext(u'Not a valid choice'))
         elif self.data:
             obj_list = list(x[1] for x in self._get_object_list())
             for v in self.data:
                 if v not in obj_list:
-                    raise ValidationError('Not a valid choice')
+                    raise ValidationError(self.gettext('Not a valid choice'))
 
 
 class ModelSelectField(QuerySelectField):