Ticket #7980: 7980_v1.diff
File 7980_v1.diff, 23.2 KB (added by , 16 years ago) |
---|
-
conf/locale/ca/LC_MESSAGES/django.po
501 501 msgid "Action" 502 502 msgstr "Acció" 503 503 504 #: contrib/admin/templates/admin/object_history.html:25505 msgid "DATE_WITH_TIME_FULL"506 msgstr "F j, Y, H:i "507 508 504 #: contrib/admin/templates/admin/object_history.html:35 509 505 msgid "" 510 506 "This object doesn't have a change history. It probably wasn't added via this " … … 4378 4374 msgid ", %(number)d %(type)s" 4379 4375 msgstr ", %(number)d %(type)s" 4380 4376 4381 #: utils/translation/trans_real.py:4034382 msgid "DATE_FORMAT"4383 msgstr "F j, Y"4384 4385 4377 #: utils/translation/trans_real.py:404 4386 msgid " DATETIME_FORMAT"4387 msgstr " F j, Y, H:i"4378 msgid "LONG_DATE_FORMAT" 4379 msgstr "l, j \\de N \\de Y" 4388 4380 4389 4381 #: utils/translation/trans_real.py:405 4382 msgid "SHORT_DATE_FORMAT" 4383 msgstr "d/m/Y" 4384 4385 #: utils/translation/trans_real.py:406 4386 msgid "LONG_DATETIME_FORMAT" 4387 msgstr "l, j \\de N \\de Y, H:i" 4388 4389 #: utils/translation/trans_real.py:407 4390 msgid "SHORT_DATETIME_FORMAT" 4391 msgstr "d/m/Y, H:i" 4392 4393 #: utils/translation/trans_real.py:408 4390 4394 msgid "TIME_FORMAT" 4391 4395 msgstr "H:i" 4392 4396 4393 #: utils/translation/trans_real.py:4 214397 #: utils/translation/trans_real.py:409 4394 4398 msgid "YEAR_MONTH_FORMAT" 4395 msgstr " j de/d' F delY"4399 msgstr "F \\de Y" 4396 4400 4397 #: utils/translation/trans_real.py:4 224401 #: utils/translation/trans_real.py:410 4398 4402 msgid "MONTH_DAY_FORMAT" 4399 msgstr "j de/d' F del Y"4403 msgstr "j \\de F" 4400 4404 4405 #: utils/translation/trans_real.py:411 4406 msgid "FIRST_DAY_OF_WEEK" 4407 msgstr "1" 4408 4409 #: utils/translation/trans_real.py:412 4410 msgid "DECIMAL_SEPARATOR" 4411 msgstr "," 4412 4413 #: utils/translation/trans_real.py:413 4414 msgid "THOUSAND_SEPARATOR" 4415 msgstr "." 4416 4401 4417 #: views/generic/create_update.py:43 4402 4418 #, python-format 4403 4419 msgid "The %(verbose_name)s was created successfully." -
conf/locale/ca/LC_MESSAGES/djangojs.po
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
57 57 msgid "S M T W T F S" 58 58 msgstr "Dg Dl Dt Dc Dj Dv Ds" 59 59 60 #: contrib/admin/media/js/calendar.js:26 61 msgid "FIRST_DAY_OF_WEEK" 62 msgstr "1" 63 60 64 #: contrib/admin/media/js/admin/DateTimeShortcuts.js:47 61 65 #: contrib/admin/media/js/admin/DateTimeShortcuts.js:81 62 66 msgid "Now" -
conf/locale/en/LC_MESSAGES/django.po
474 474 msgid "Action" 475 475 msgstr "" 476 476 477 #: contrib/admin/templates/admin/object_history.html:25478 msgid "DATE_WITH_TIME_FULL"479 msgstr "N j, Y, P"480 481 477 #: contrib/admin/templates/admin/object_history.html:35 482 478 msgid "" 483 479 "This object doesn't have a change history. It probably wasn't added via this " … … 3732 3728 msgid ", %(number)d %(type)s" 3733 3729 msgstr "" 3734 3730 3735 #: utils/translation/trans_real.py: 3993736 msgid " DATE_FORMAT"3731 #: utils/translation/trans_real.py:405 3732 msgid "LONG_DATE_FORMAT" 3737 3733 msgstr "N j, Y" 3738 3734 3739 #: utils/translation/trans_real.py:400 3740 msgid "DATETIME_FORMAT" 3735 #: utils/translation/trans_real.py:406 3736 msgid "SHORT_DATE_FORMAT" 3737 msgstr "m/d/Y" 3738 3739 #: utils/translation/trans_real.py:407 3740 msgid "LONG_DATETIME_FORMAT" 3741 3741 msgstr "N j, Y, P" 3742 3742 3743 #: utils/translation/trans_real.py:401 3743 #: utils/translation/trans_real.py:408 3744 msgid "SHORT_DATETIME_FORMAT" 3745 msgstr "m/d/Y, P" 3746 3747 #: utils/translation/trans_real.py:409 3744 3748 msgid "TIME_FORMAT" 3745 3749 msgstr "P" 3746 3750 3747 #: utils/translation/trans_real.py:41 73751 #: utils/translation/trans_real.py:410 3748 3752 msgid "YEAR_MONTH_FORMAT" 3749 3753 msgstr "F Y" 3750 3754 3751 #: utils/translation/trans_real.py:41 83755 #: utils/translation/trans_real.py:411 3752 3756 msgid "MONTH_DAY_FORMAT" 3753 3757 msgstr "F j" 3754 3758 3759 #: utils/translation/trans_real.py:412 3760 msgid "FIRST_DAY_OF_WEEK" 3761 msgstr "0" 3762 3763 #: utils/translation/trans_real.py:413 3764 msgid "DECIMAL_SEPARATOR" 3765 msgstr "," 3766 3767 #: utils/translation/trans_real.py:414 3768 msgid "THOUSAND_SEPARATOR" 3769 msgstr "." 3770 3755 3771 #: views/generic/create_update.py:43 3756 3772 #, python-format 3757 3773 msgid "The %(verbose_name)s was created successfully." -
conf/locale/en/LC_MESSAGES/djangojs.po
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
56 56 msgid "S M T W T F S" 57 57 msgstr "" 58 58 59 #: contrib/admin/media/js/calendar.js:26 60 msgid "FIRST_DAY_OF_WEEK" 61 msgstr "0" 62 59 63 #: contrib/admin/media/js/dateparse.js:33 60 64 msgid "Sunday Monday Tuesday Wednesday Thursday Friday Saturday" 61 65 msgstr "" -
conf/global_settings.py
249 249 # (i.e. "/tmp" on *nix systems). 250 250 FILE_UPLOAD_TEMP_DIR = None 251 251 252 # Default formatting for date objects. See all available format strings here:252 # Default formatting for long date objects. See all available format strings here: 253 253 # http://www.djangoproject.com/documentation/templates/#now 254 DATE_FORMAT = 'N j, Y'254 LONG_DATE_FORMAT = 'N j, Y' 255 255 256 # Default formatting for datetime objects. See all available format strings here:256 # Default formatting for short date objects. See all available format strings here: 257 257 # http://www.djangoproject.com/documentation/templates/#now 258 DATETIME_FORMAT = 'N j, Y, P'258 SHORT_DATE_FORMAT = 'm/d/Y' 259 259 260 # Default formatting for long datetime objects. See all available format strings here: 261 # http://www.djangoproject.com/documentation/templates/#now 262 LONG_DATETIME_FORMAT = 'N j, Y, P' 263 264 # Default formatting for short datetime objects. See all available format strings here: 265 # http://www.djangoproject.com/documentation/templates/#now 266 SHORT_DATETIME_FORMAT = 'm/d/Y P' 267 260 268 # Default formatting for time objects. See all available format strings here: 261 269 # http://www.djangoproject.com/documentation/templates/#now 262 270 TIME_FORMAT = 'P' … … 271 279 # http://www.djangoproject.com/documentation/templates/#now 272 280 MONTH_DAY_FORMAT = 'F j' 273 281 282 # Default value for first day of week on calendars. 0 is Sunday, 1 is Monday... 283 FIRST_DAY_OF_WEEK = '0' 284 285 # Default value used as decimal separator when formatting numbers. 286 DECIMAL_SEPARATOR = '.' 287 288 # Default value used as thousand separator when formatting numbers. 289 THOUSAND_SEPARATOR = ',' 290 274 291 # Do you want to manage transactions manually? 275 292 # Hint: you really don't! 276 293 TRANSACTIONS_MANAGED = False -
utils/translation/trans_real.py
4 4 import os 5 5 import re 6 6 import sys 7 import decimal 8 import datetime 7 9 import gettext as gettext_module 8 10 from cStringIO import StringIO 9 11 12 from django.utils import dateformat 10 13 from django.utils.safestring import mark_safe, SafeData 11 14 from django.utils.thread_support import currentThread 12 15 … … 391 394 392 395 return settings.LANGUAGE_CODE 393 396 394 def get_ date_formats():397 def get_formats(): 395 398 """ 396 399 Checks whether translation files provide a translation for some technical 397 message ID to store date and timeformats. If it doesn't contain one, the400 message ID to store date, time and number formats. If it doesn't contain one, the 398 401 formats provided in the settings will be used. 399 402 """ 400 403 from django.conf import settings 401 date_format = ugettext('DATE_FORMAT') 402 datetime_format = ugettext('DATETIME_FORMAT') 403 time_format = ugettext('TIME_FORMAT') 404 if date_format == 'DATE_FORMAT': 405 date_format = settings.DATE_FORMAT 406 if datetime_format == 'DATETIME_FORMAT': 407 datetime_format = settings.DATETIME_FORMAT 408 if time_format == 'TIME_FORMAT': 409 time_format = settings.TIME_FORMAT 410 return date_format, datetime_format, time_format 404 formats = {} 405 formats['LONG_DATE_FORMAT'] = ugettext('LONG_DATE_FORMAT') 406 formats['SHORT_DATE_FORMAT'] = ugettext('SHORT_DATE_FORMAT') 407 formats['LONG_DATETIME_FORMAT'] = ugettext('LONG_DATETIME_FORMAT') 408 formats['SHORT_DATETIME_FORMAT'] = ugettext('SHORT_DATETIME_FORMAT') 409 formats['TIME_FORMAT'] = ugettext('TIME_FORMAT') 410 formats['YEAR_MONTH_FORMAT'] = ugettext('YEAR_MONTH_FORMAT') 411 formats['MONTH_DAY_FORMAT'] = ugettext('MONTH_DAY_FORMAT') 412 formats['FIRST_DAY_OF_WEEK'] = ugettext('FIRST_DAY_OF_WEEK') 413 formats['DECIMAL_SEPARATOR'] = ugettext('DECIMAL_SEPARATOR') 414 formats['THOUSAND_SEPARATOR'] = ugettext('THOUSAND_SEPARATOR') 415 416 for format_name, format_value in formats.iteritems(): 417 if format_name == format_value: 418 formats[format_name] = getattr(settings, format_name) 411 419 412 def get_partial_date_formats(): 420 return formats 421 422 def i18ize(value): 413 423 """ 414 Checks whether translation files provide a translation for some technical 415 message ID to store partial date formats. If it doesn't contain one, the 416 formats provided in the settings will be used. 424 Converts a date/time or decimal number to a string, using the format defined 425 for current locale. 417 426 """ 418 from django.conf import settings 419 year_month_format = ugettext('YEAR_MONTH_FORMAT') 420 month_day_format = ugettext('MONTH_DAY_FORMAT') 421 if year_month_format == 'YEAR_MONTH_FORMAT': 422 year_month_format = settings.YEAR_MONTH_FORMAT 423 if month_day_format == 'MONTH_DAY_FORMAT': 424 month_day_format = settings.MONTH_DAY_FORMAT 425 return year_month_format, month_day_format 427 formats = get_formats() 428 if isinstance(value, decimal.Decimal): 429 return str(value).replace('.', formats['DECIMAL_SEPARATOR']) 430 elif isinstance(value, datetime.date): 431 return dateformat.format(value, formats['LONG_DATE_FORMAT']) 432 elif isinstance(value, datetime.datetime): 433 return dateformat.format(value, formats['LONG_DATETIME_FORMAT']) 434 else: 435 return value 426 436 427 437 dot_re = re.compile(r'\S') 428 438 def blankout(src, char): -
utils/translation/__init__.py
6 6 7 7 __all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext', 8 8 'ngettext_lazy', 'string_concat', 'activate', 'deactivate', 9 'get_language', 'get_language_bidi', 'get_date_formats', 10 'get_partial_date_formats', 'check_for_language', 'to_locale', 11 'get_language_from_request', 'templatize', 'ugettext', 12 'ungettext', 'deactivate_all'] 9 'get_language', 'get_language_bidi', 'get_formats', 'i18ize', 10 'check_for_language', 'to_locale', 'get_language_from_request', 11 'templatize', 'ugettext', 'ungettext', 'deactivate_all'] 13 12 14 13 # Here be dragons, so a short explanation of the logic won't hurt: 15 14 # We are trying to solve two problems: (1) access settings, in particular … … 81 80 def get_language_bidi(): 82 81 return real_get_language_bidi() 83 82 84 def get_ date_formats():85 return real_get_ date_formats()83 def get_formats(): 84 return real_get_formats() 86 85 87 def get_partial_date_formats():88 return real_ get_partial_date_formats()86 def i18ize(value): 87 return real_i18ize(value) 89 88 90 89 def check_for_language(lang_code): 91 90 return real_check_for_language(lang_code) -
utils/translation/trans_null.py
18 18 deactivate = deactivate_all = lambda: None 19 19 get_language = lambda: settings.LANGUAGE_CODE 20 20 get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI 21 get_date_formats = lambda: (settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT)22 get_partial_date_formats = lambda: (settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT)23 21 check_for_language = lambda x: True 24 22 25 23 TECHNICAL_ID_MAP = { … … 51 49 52 50 def get_language_from_request(request): 53 51 return settings.LANGUAGE_CODE 52 53 def get_formats(): 54 formats = ('LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT', 'LONG_DATETIME_FORMAT', 55 'SHORT_DATETIME_FORMAT', 'TIME_FORMAT', 'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 56 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR', 'THOUSAND_SEPARATOR') 57 result = {} 58 for format in formats: 59 result[format] = getattr(settings, format) 60 return result 61 62 def i18ize(value): 63 return value -
contrib/admin/media/js/calendar.js
25 25 var CalendarNamespace = { 26 26 monthsOfYear: gettext('January February March April May June July August September October November December').split(' '), 27 27 daysOfWeek: gettext('S M T W T F S').split(' '), 28 firstDayOfWeek: parseInt(gettext('FIRST_DAY_OF_WEEK').replace('FIRST_DAY_OF_WEEK', '0')), 28 29 isLeapYear: function(year) { 29 30 return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)); 30 31 }, … … 56 57 // Draw days-of-week header 57 58 var tableRow = quickElement('tr', tableBody); 58 59 for (var i = 0; i < 7; i++) { 59 quickElement('th', tableRow, CalendarNamespace.daysOfWeek[ i]);60 quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]); 60 61 } 61 62 62 63 var startingPos = new Date(year, month-1, 1).getDay(); -
contrib/admin/templatetags/admin_list.py
7 7 from django.utils.html import escape, conditional_escape 8 8 from django.utils.text import capfirst 9 9 from django.utils.safestring import mark_safe 10 from django.utils.translation import get_ date_formats, get_partial_date_formats, ugettext as _10 from django.utils.translation import get_formats, ugettext as _ 11 11 from django.utils.encoding import smart_unicode, smart_str, force_unicode 12 12 from django.template import Library 13 13 import datetime … … 153 153 else: 154 154 field_val = getattr(result, f.attname) 155 155 156 formats = get_formats() 156 157 if isinstance(f.rel, models.ManyToOneRel): 157 158 if field_val is not None: 158 159 result_repr = escape(getattr(result, f.name)) … … 161 162 # Dates and times are special: They're formatted in a certain way. 162 163 elif isinstance(f, models.DateField) or isinstance(f, models.TimeField): 163 164 if field_val: 164 (date_format, datetime_format, time_format) = get_date_formats()165 165 if isinstance(f, models.DateTimeField): 166 result_repr = capfirst(dateformat.format(field_val, datetime_format))166 result_repr = capfirst(dateformat.format(field_val, formats['LONG_DATETIME_FORMAT'])) 167 167 elif isinstance(f, models.TimeField): 168 result_repr = capfirst(dateformat.time_format(field_val, time_format))168 result_repr = capfirst(dateformat.time_format(field_val, formats['TIME_FORMAT'])) 169 169 else: 170 result_repr = capfirst(dateformat.format(field_val, date_format))170 result_repr = capfirst(dateformat.format(field_val, formats['LONG_DATE_FORMAT'])) 171 171 else: 172 172 result_repr = EMPTY_CHANGELIST_VALUE 173 173 row_class = ' class="nowrap"' … … 177 177 # DecimalFields are special: Zero-pad the decimals. 178 178 elif isinstance(f, models.DecimalField): 179 179 if field_val is not None: 180 result_repr = ( '%%.%sf' % f.decimal_places) % field_val180 result_repr = (('%%.%sf' % f.decimal_places) % field_val).replace('.', formats['DECIMAL_SEPARATOR']) 181 181 else: 182 182 result_repr = EMPTY_CHANGELIST_VALUE 183 183 # Fields with choices are special: Use the representation … … 221 221 year_lookup = cl.params.get(year_field) 222 222 month_lookup = cl.params.get(month_field) 223 223 day_lookup = cl.params.get(day_field) 224 year_month_format, month_day_format = get_partial_date_formats()224 formats = get_formats() 225 225 226 226 link = lambda d: mark_safe(cl.get_query_string(d, [field_generic])) 227 227 … … 231 231 'show': True, 232 232 'back': { 233 233 'link': link({year_field: year_lookup, month_field: month_lookup}), 234 'title': dateformat.format(day, year_month_format)234 'title': dateformat.format(day, formats['YEAR_MONTH_FORMAT']) 235 235 }, 236 'choices': [{'title': dateformat.format(day, month_day_format)}]236 'choices': [{'title': dateformat.format(day, formats['MONTH_DAY_FORMAT'])}] 237 237 } 238 238 elif year_lookup and month_lookup: 239 239 days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day') … … 245 245 }, 246 246 'choices': [{ 247 247 'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}), 248 'title': dateformat.format(day, month_day_format)248 'title': dateformat.format(day, formats['MONTH_DAY_FORMAT']) 249 249 } for day in days] 250 250 } 251 251 elif year_lookup: … … 258 258 }, 259 259 'choices': [{ 260 260 'link': link({year_field: year_lookup, month_field: month.month}), 261 'title': dateformat.format(month, year_month_format)261 'title': dateformat.format(month, formats['YEAR_MONTH_FORMAT']) 262 262 } for month in months] 263 263 } 264 264 else: -
contrib/admin/templates/admin/object_history.html
21 21 <tbody> 22 22 {% for action in action_list %} 23 23 <tr> 24 <th scope="row">{{ action.action_time |date:_("DATE_WITH_TIME_FULL")}}</th>24 <th scope="row">{{ action.action_time }}</th> 25 25 <td>{{ action.user.username }}{% if action.user.first_name %} ({{ action.user.first_name }} {{ action.user.last_name }}){% endif %}</td> 26 26 <td>{{ action.change_message }}</td> 27 27 </tr> -
contrib/databrowse/datastructures.py
6 6 from django.db import models 7 7 from django.utils import dateformat 8 8 from django.utils.text import capfirst 9 from django.utils.translation import get_ date_formats9 from django.utils.translation import get_formats 10 10 from django.utils.encoding import smart_unicode, smart_str, iri_to_uri 11 11 from django.utils.safestring import mark_safe 12 12 from django.db.models.query import QuerySet … … 156 156 objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE) 157 157 elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField): 158 158 if self.raw_value: 159 date_format, datetime_format, time_format = get_date_formats()159 formats = get_formats() 160 160 if isinstance(self.field, models.DateTimeField): 161 objs = capfirst(dateformat.format(self.raw_value, datetime_format))161 objs = capfirst(dateformat.format(self.raw_value, formats['DATETIME_FORMAT'])) 162 162 elif isinstance(self.field, models.TimeField): 163 objs = capfirst(dateformat.time_format(self.raw_value, time_format))163 objs = capfirst(dateformat.time_format(self.raw_value, formats['TIME_FORMAT'])) 164 164 else: 165 objs = capfirst(dateformat.format(self.raw_value, date_format))165 objs = capfirst(dateformat.format(self.raw_value, formats['DATE_FORMAT'])) 166 166 else: 167 167 objs = EMPTY_VALUE 168 168 elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField): -
template/__init__.py
56 56 from django.utils.functional import curry, Promise 57 57 from django.utils.text import smart_split 58 58 from django.utils.encoding import smart_unicode, force_unicode 59 from django.utils.translation import ugettext as _59 from django.utils.translation import i18ize, ugettext as _ 60 60 from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping 61 61 from django.utils.html import escape 62 62 … … 782 782 783 783 def render(self, context): 784 784 try: 785 output = force_unicode(self.filter_expression.resolve(context)) 785 value = self.filter_expression.resolve(context) 786 i18n_value = i18ize(value) 787 output = force_unicode(i18n_value) 786 788 except UnicodeDecodeError: 787 789 # Unicode conversion can fail sometimes for reasons out of our 788 790 # control (e.g. exception rendering). In that case, we fail quietly. -
template/debug.py
1 import decimal, datetime 1 2 from django.template import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError 2 3 from django.utils.encoding import force_unicode 3 4 from django.utils.html import escape … … 2 3 from django.utils.safestring import SafeData, EscapeData 4 from django.utils.translation import i18ize 3 5 … … 84 86 class DebugVariableNode(VariableNode): 85 87 def render(self, context): 86 88 try: 87 output = force_unicode(self.filter_expression.resolve(context)) 89 value = self.filter_expression.resolve(context) 90 i18n_value = i18ize(value) 91 output = force_unicode(i18n_value) 88 92 except TemplateSyntaxError, e: 89 93 if not hasattr(e, 'source'): 90 94 e.source = self.source