5👍
The translations of those strings are already done by the django project : https://github.com/django/django/blob/master/django/contrib/auth/locale/es_MX/LC_MESSAGES/django.po#L42
You don’t need to make your own translation.
You should already have them translated in your app.
3👍
If you are using a ModelForm, check out this answer for customizing labels and error messages:
class AuthorForm(ModelForm):
class Meta:
model = Author
fields = ('name', 'title', 'birth_date')
labels = {
'name': _('Writer'),
}
help_texts = {
'name': _('Some useful help text.'),
}
error_messages = {
'name': {
'max_length': _("This writer's name is too long."),
},
}
- [Django]-How can this be written on a single line?
- [Django]-Formatting inline many-to-many related models presented in django admin
- [Django]-Disable django context processor in django-admin pages
- [Django]-Postgres to Ubuntu Docker container linking not working
- [Django]-Get the first element in the for loops in the Django template
2👍
As mentioned above, the translation comes with Django. However if the translation is not complete for language you want or does not match your wishes, you can always copy string to translate to your project and your translations will take precedence over ones shipped with Django.
To achieve that simply create file and include these strings to translate. For example app/i18n.py
:
'''
Fake file to translate messages from django.contrib.auth.
'''
def _(text):
return text
def fake():
_(u'This username is already taken. Please choose another.')
Now makemessages
will pick up these strings and you will be able to transalte them.