Opened 5 years ago
Last modified 5 years ago
#31132 closed Bug
Django Internationalization Issue — at Initial Version
Reported by: | Tiago Borges | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 2.2 |
Severity: | Normal | Keywords: | internationalization |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a application in django 2.2 to translate just as below:
LANGUAGES = ( ('pt', _('Portuguese')), ('en', _('English')), ('es', _('Spanish')), ) LANGUAGE_CODE = 'en'
The translation itself is working on the templates and for the default language (LANGUAGE_CODE). The issue lies on the translation triggering. Since this is for a REST api, I will not be using cookies or sessions, the translation needs to watch the Accept-Language
header. Debugging the Locale middleware, I can confirm that the correct language is being found, but the translated text are returned always for the default language (LANGUAGE_CODE), ignoring the language found by the middleware. If I replace the LANGUAGE_CODE
for pt or es, it works just fine. The django docs states that LANGUAGE_CODE
was supposed to be the last fallback.