Why doesn't DRF translate dutch?
DRF automatically translates response messages for some languages if the right 'Accept-Language' header is present. It does this as expected for e.g. Spanish ('es') and French ('fr'), but apparently not for Dutch ('nl') even though all the necessary translations are available.
DRF provides a way to add new translations. But since the translations are already made, this should not be necessary.
Django settings (no LANGUAGES setting):
MIDDLEWARE = [
...
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
...
]
USE_I18N = True
USE_L10N = True
USE_TZ = True
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
Behaviour with other languages:
http http://localhost:8000/api/auth/password/reset/ Accept-Language:es
...
Content-Language: es
...
{
"detail": "Método \"GET\" no permitido."
}
Behaviour with dutch:
http http://localhost:8000/api/auth/password/reset/ Accept-Language:nl
...
Content-Language: nl
...
{
"detail": "Method \"GET\" not allowed."
}
Expected behaviour with dutch (source):
http http://localhost:8000/api/auth/password/reset/ Accept-Language:nl
...
Content-Language: nl
...
{
"detail": "Methode \"GET\" niet toegestaan."
}
django version: 2.1
djangorestframework version: 3.8.0
Could not replicate this issue with the following requirements:
Django==2.2
djangorestframework==3.9.2
pytz==2018.9
sqlparse==0.3.0
Updating solves your problem I guess, although the translation is added in 3.2*.
- https://github.com/encode/django-rest-framework/blame/b1122a441aeab5664b43351378b63e5dd87ab7a5/rest_framework/locale/nl/LC_MESSAGES/django.po#L132
Could not replicate this issue
I'll close this off unless we've got confirmation from elsewhere that this is an issue. Thanks @foarsitter
Figured it out. My project has some other dutch translations. The problem starts occurring when I compile these messages. My django.po file only contains messages related to my project codebase, but it is treated as if custom DRF translations are provided. Isn't there some other cleaner way to include the already translated DRF messages without having to copy the newest dutch DRF translations from some link into my already existing django.po file with my own translations?
@blievrouw no idea. This would be a good idea to ask on the Django user mailing list since DRF is "a Django application that comes provided with translation".