Ticket #5789: 5789.patch

File 5789.patch, 3.7 KB (added by John DeRosa, 17 years ago)
  • django/utils/translation/trans_real.py

     
    350350    supported = dict(settings.LANGUAGES)
    351351
    352352    if hasattr(request, 'session'):
    353         lang_code = request.session.get('django_language', None)
     353        lang_code = request.session.get('_language', None)
    354354        if lang_code in supported and lang_code is not None and check_for_language(lang_code):
    355355            return lang_code
    356356
  • django/views/i18n.py

     
    11from django import http
    2 from django.utils.translation import check_for_language, activate, to_locale, get_language
     2from django.utils.translation import check_for_language, activate, to_locale
     3from django.utils.translation import get_language
    34from django.utils.text import javascript_quote
    45from django.conf import settings
    56import os
     
    2627        lang_code = request.POST.get('language', None)
    2728        if lang_code and check_for_language(lang_code):
    2829            if hasattr(request, 'session'):
    29                 request.session['django_language'] = lang_code
     30                request.session['_language'] = lang_code
    3031            else:
    3132                response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
    3233    return response
  • docs/i18n.txt

     
    545545``LocaleMiddleware`` tries to determine the user's language preference by
    546546following this algorithm:
    547547
    548     * First, it looks for a ``django_language`` key in the the current user's
     548    * First, it looks for a ``_language`` key in the the current user's
    549549      `session`_.
    550     * Failing that, it looks for a cookie that is named according to your ``LANGUAGE_COOKIE_NAME`` setting. (The default name is ``django_language``, and this setting is new in the Django development version. In Django version 0.96 and before, the cookie's name is hard-coded to ``django_language``.)
     550    * Failing that, it looks for a cookie that is named according to your ``LANGUAGE_COOKIE_NAME`` setting. (The default name is ``django_language``, and this setting is new in the Django development version. In Django version 0.96 and earlier, the cookie's name is hard-coded to ``django_language``.)
    551551    * Failing that, it looks at the ``Accept-Language`` HTTP header. This
    552552      header is sent by your browser and tells the server which language(s) you
    553553      prefer, in order by priority. Django tries each language in the header
     
    859859    * Django doesn't use ``xgettext`` alone. It uses Python wrappers around
    860860      ``xgettext`` and ``msgfmt``. This is mostly for convenience.
    861861
     862
  • tests/regressiontests/views/tests/i18n.py

     
    1616            post_data = dict(language=lang_code, next='/views/')
    1717            response = self.client.post('/views/i18n/setlang/', data=post_data)
    1818            self.assertRedirects(response, 'http://testserver/views/')
    19             self.assertEquals(self.client.session['django_language'], lang_code)
     19            self.assertEquals(self.client.session['_language'], lang_code)
    2020
    2121    def test_jsi18n(self):
    2222        """The javascript_catalog can be deployed with language settings"""
Back to Top