2

How would I go about translating a validation error that is automatically generated by Django? I'm seeing that when a user attempts to add an invalid username, the Validation error is not translated. Is there a way to mark the built-in validation error for translation?

enter image description here

My error is currently generated by validating a Form that is generated using the built-in User model.

class UserForm(ModelForm):

    email = forms.CharField(max_length=75, required=True, label=_('Email'))
    password = forms.CharField(
        widget=forms.PasswordInput(), label=_('Password'))

    class Meta:
        model = User
        fields = (
            'username',
            'first_name',
            'last_name',
            'email',
            'password',
        )
orange1
  • 2,871
  • 3
  • 32
  • 58
  • what your languange? – binpy Feb 20 '17 at 16:46
  • @Sanca The language is Spanish – orange1 Feb 20 '17 at 17:13
  • I checked at the [source](https://github.com/django/django/blob/master/django/contrib/auth/locale/es/LC_MESSAGES/django.po#L283-L286), and spanish not translated yet... I suggest you to check this related question; http://stackoverflow.com/questions/7878028/override-default-django-translations, or contribute to translate the django at [transifex](https://www.transifex.com/django/django) to support your own language. – binpy Feb 20 '17 at 17:26
  • Other optional, simply way to overwrite a message on form, you can checkout at [this answer](http://stackoverflow.com/a/1488660/6396981) – binpy Feb 20 '17 at 17:34

0 Answers0