How do I tell why Django is ignoring the Accept-Language header?

I have a Django app (on Google App Engine) that I wish to internationalize.

USE_I18N = True

# Restrict supported languages (and JS media generation)
  ('en', 'English'),
  ('fr', 'French'),

  # i18n

I have generated .po and .mo files for my app in locale/fr/LC_MESSAGES (though not at the global level).

I set my browser Accept-Language heading to "fr" and Django ignores it. When I look at request.LANGUAGE_CODE it is always "en".

I can tell the browser is proper because I visit some other i18n-aware site and it returns French.

How do I find what Django thinks is missing about my setup?

I saw this question and it didn't help me.

I am running Django 1.0 using app engine patch on Google App Engine.


There's a certain order that Django does things in terms of i18n.

First it checks LANGUAGE_CODE. It's the site-wide language and if nothing else is set, this is the language the user gets.

Second, since you've added the LocaleMiddleware, it checks if django_language is set in the user session. I would suggest clearing the session information in the DB or creating a completely new user to try with.

Third, it checks if there's a django_language cookie set (or, actually, the name of the cookie is defined by the LANGUAGE_COOKIE_NAME). I would suggest deleting this cookie.

Fourth, it looks for the Accept-Language HTTP header. Which is where your browser setting comes in.

Good luck!

Need Your Help

Mulesoft download zip file via APIKit Router

anypoint-studio apikit

I am having trouble with browser showing save/download prompt for zip file on http endpoint wiht APIKit Router.

How to implement transaction in Spring Data Redis in a clean way?

java spring redis spring-data-redis

I am following RetwisJ tutorial available here. In this I don't think Redis transactions are implemented. For example, in the following function, if some exception occurs in between, the data will be