Django

Code

Changeset 7185

Show
Ignore:
Timestamp:
02/29/08 12:38:44 (1 year ago)
Author:
mtredinnick
Message:

Fixed #5603 -- Allow customization of the language cookie name. Thanks, moe.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/conf/global_settings.py

    r7135 r7185  
    9292# to load the internationalization machinery. 
    9393USE_I18N = True 
    94  
    9594LOCALE_PATHS = () 
     95LANGUAGE_COOKIE_NAME = 'django_language' 
    9696 
    9797# Not-necessarily-technical managers of the site. They get broken link 
  • django/trunk/django/utils/translation/trans_real.py

    r7091 r7185  
    356356            return lang_code 
    357357 
    358     lang_code = request.COOKIES.get('django_language'
     358    lang_code = request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME
    359359    if lang_code and lang_code in supported and check_for_language(lang_code): 
    360360        return lang_code 
  • django/trunk/django/views/i18n.py

    r6739 r7185  
    2929                request.session['django_language'] = lang_code 
    3030            else: 
    31                 response.set_cookie('django_language', lang_code) 
     31                response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code) 
    3232    return response 
    3333 
  • django/trunk/docs/i18n.txt

    r7059 r7185  
    548548    * First, it looks for a ``django_language`` key in the the current user's 
    549549      `session`_. 
    550     * Failing that, it looks for a cookie called ``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``)
    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 
     
    720720parameter set in request. If session support is enabled, the view 
    721721saves the language choice in the user's session. Otherwise, it saves the 
    722 language choice in a ``django_language`` cookie. 
     722language choice in a cookie that is by default named ``django_language`` 
     723(the name can be changed through the ``LANGUAGE_COOKIE_NAME`` setting). 
    723724 
    724725After setting the language choice, Django redirects the user, following this 
  • django/trunk/docs/settings.txt

    r6930 r7185  
    579579 
    580580.. _internationalization docs: ../i18n/ 
     581 
     582LANGUAGE_COOKIE_NAME 
     583-------------------- 
     584 
     585Default: ``'django_language'`` 
     586 
     587The name of the cookie to use for the language cookie. This can be whatever 
     588you want (but should be different from SESSION_COOKIE_NAME). See the 
     589`internationalization docs`_ for details. 
     590 
    581591 
    582592LANGUAGES 
     
    823833Default: ``'sessionid'`` 
    824834 
    825 The name of the cookie to use for sessions. This can be whatever you want. 
    826 See the `session docs`_. 
     835The name of the cookie to use for sessions. This can be whatever you want (but 
     836should be different from ``LANGUAGE_COOKIE_NAME``). See the `session docs`_. 
    827837 
    828838SESSION_COOKIE_PATH