Skip to content

Not picking up Danish translations #4469

@vesterbaek

Description

@vesterbaek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy