Django

Code

Changeset 3056

Show
Ignore:
Timestamp:
06/01/06 23:26:07 (2 years ago)
Author:
adrian
Message:

Fixed #2063 -- Made admin date_hierarchy i18n-friendly by using the new YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT technical message IDs. Thanks, ramiro

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/templatetags/admin_list.py

    r2844 r3056  
    33from django.contrib.admin.views.main import MAX_SHOW_ALL_ALLOWED, ALL_VAR 
    44from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR 
    5 from django.contrib.admin.views.main import IS_POPUP_VAR, EMPTY_CHANGELIST_VALUE, MONTHS 
     5from django.contrib.admin.views.main import IS_POPUP_VAR, EMPTY_CHANGELIST_VALUE 
    66from django.core.exceptions import ObjectDoesNotExist 
    77from django.db import models 
     
    99from django.utils.html import escape 
    1010from django.utils.text import capfirst 
    11 from django.utils.translation import get_date_formats 
     11from django.utils.translation import get_date_formats, get_partial_date_formats 
    1212from django.template import Library 
     13import datetime 
    1314 
    1415register = Library() 
     
    194195        month_lookup = cl.params.get(month_field) 
    195196        day_lookup = cl.params.get(day_field) 
     197        year_month_format, month_day_format = get_partial_date_formats() 
    196198 
    197199        link = lambda d: cl.get_query_string(d, [field_generic]) 
    198200 
    199201        if year_lookup and month_lookup and day_lookup: 
    200             month_name = MONTHS[int(month_lookup)] 
     202            day = datetime.date(int(year_lookup), int(month_lookup), int(day_lookup)) 
    201203            return { 
    202204                'show': True, 
    203205                'back': { 
    204206                    'link': link({year_field: year_lookup, month_field: month_lookup}), 
    205                     'title': "%s %s" % (month_name, year_lookup
     207                    'title': dateformat.format(day, year_month_format
    206208                }, 
    207                 'choices': [{'title': "%s %s" % (month_name, day_lookup)}] 
     209                'choices': [{'title': dateformat.format(day, month_day_format)}] 
    208210            } 
    209211        elif year_lookup and month_lookup: 
     
    217219                'choices': [{ 
    218220                    'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}), 
    219                     'title': day.strftime('%B %d'
     221                    'title': dateformat.format(day, month_day_format
    220222                } for day in days] 
    221223            } 
     
    230232                'choices': [{ 
    231233                    'link': link({year_field: year_lookup, month_field: month.month}), 
    232                     'title': "%s %s" % (month.strftime('%B'), month.year
     234                    'title': dateformat.format(month, year_month_format
    233235                } for month in months] 
    234236            }