Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Suggestion/answer:</p> <p>I got some weird behaviour on that also! Because I was forgetting to add the 'LocaleMiddleware', double check if it is there, for illustration this is how my 'MIDDLEWARE_CLASSES' looks like:</p> <pre><code>MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) </code></pre> <p>That Middleware is responsible for process your request and response, and add the language!</p> <p>Also keep the code from 'Sindri Guðmundsson', which is changing right the lang!</p> <p><strong>EDIT</strong></p> <p>A little bit further! If we take a look at LocaleMiddleware:</p> <pre><code>def process_request(self, request): language = translation.get_language_from_request(request) translation.activate(language) request.LANGUAGE_CODE = translation.get_language() </code></pre> <p>So the question is! why Django needs that?! the answer: Because if you use {{ LANGUAGE_CODE }} it is reading from the REQUEST, so LANGUAGE_CODE must be in the request! otherwise ! it is not going to return it! so thats why this middleware exist! Check it out the comment, in the actual source code of the middleware:</p> <pre><code>""" This is a very simple middleware that parses a request and decides what translation object to install in the current thread context. This allows pages to be dynamically translated to the language the user desires (if the language is available, of course). """ </code></pre> <p>Also check the docs: <a href="https://docs.djangoproject.com/en/1.3/topics/i18n/deployment/#how-django-discovers-language-preference" rel="nofollow">https://docs.djangoproject.com/en/1.3/topics/i18n/deployment/#how-django-discovers-language-preference</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload