[Internationalization] Django not falling back to base language

7 views
Skip to first unread message

Dibya Chakravorty

unread,
Mar 15, 2017, 7:29:14 AM3/15/17
to Django users
Hi everyone,

I set the LANGUAGE_SESSION_KEY key in the current user's session to "en_US" (also tried with "en-us"), and my LANGUAGES settings is as follows:

LANGUAGES = [
    ('de', _('German')),
    ('en', _('English')),
]


According to the docs, Django should fall back to the base language "en" in this case. However, it doesn't.

While hunting down the bug, I stumbled upon django.utils.translation.trans_real, where the function responsible for discovering the appropriate
language is defined. It's called get_language_from_request.

At first glance, it looks like this function falls back to the base language for all the other modes of language discovery (URL, Cookies, Accept-Language header etc.)
but not when it reads from the user's session.

If anyone has knowledge about this issue, I would like to know:

1. Is this intended behavior or is this a bug?
2. Or am I doing something totally stupid?

Thanks for your help,
Dibya
Reply all
Reply to author
Forward
0 new messages