-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
I'm sending requests with "Accept-Language: da". Translations originating from Django (eg. "This field is required.") and translations in my own apps work. Strings in rest framework always are always returned in english, eg. "This field may not be blank.". Looking into the locale folder of rest framework, I can see both "da" and "da_DK" where "da_DK" contains empty strings only.
If I delete the da_DK folder in rest_framework, the Danish translations work. From looking at the gettext documentation, it seems empty value ""
means use the key as value.
I also looked a bit into the internals of Django wrt. translation in trans_real.py and gettext.py in gettext. My current language is correctly set to "da". gettext finds da/LC_MESSAGES/django.mo, da_DK/LC_MESSAGES/django.mo based on the locale dir provided to it by Django. gettext chains the two files via a _fallback parameter. And returns this to Django. Django then merges the translations from the given app into one translation dict.
I couldn't entirely understand if the problem with the empty values are from gettext parsing of the mo-files where it replaces empty value with key or it's from Django's merging of the translation objects. Bottom line is that if I remove the empty entries (i.e. delete the da_DK dir) it works.