1
0
mirror of https://github.com/django/django.git synced 2025-03-14 03:10:45 +00:00

Fixed -- Allowed whitespace in admin's calendar.js month/weekday names.

This is useful for certain language translations.
This commit is contained in:
bphillips 2015-11-27 14:08:08 -05:00 committed by Tim Graham
parent 717a54c883
commit 7f663aeccf
2 changed files with 29 additions and 8 deletions
django/contrib/admin/static/admin/js
tests/admin_widgets

@ -1,4 +1,4 @@
/*global gettext, get_format, quickElement, removeChildren*/ /*global gettext, pgettext, get_format, quickElement, removeChildren*/
/* /*
calendar.js - Calendar functions by Adrian Holovaty calendar.js - Calendar functions by Adrian Holovaty
depends on core.js for utility functions like removeChildren or quickElement depends on core.js for utility functions like removeChildren or quickElement
@ -8,8 +8,29 @@ depends on core.js for utility functions like removeChildren or quickElement
'use strict'; 'use strict';
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
var CalendarNamespace = { var CalendarNamespace = {
monthsOfYear: gettext('January February March April May June July August September October November December').split(' '), monthsOfYear: [
daysOfWeek: gettext('S M T W T F S').split(' '), gettext('January'),
gettext('February'),
gettext('March'),
gettext('April'),
gettext('May'),
gettext('June'),
gettext('July'),
gettext('August'),
gettext('September'),
gettext('October'),
gettext('November'),
gettext('December')
],
daysOfWeek: [
pgettext('one letter Sunday', 'S'),
pgettext('one letter Monday', 'M'),
pgettext('one letter Tuesday', 'T'),
pgettext('one letter Wednesday', 'W'),
pgettext('one letter Thursday', 'T'),
pgettext('one letter Friday', 'F'),
pgettext('one letter Saturday', 'S')
],
firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')), firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')),
isLeapYear: function(year) { isLeapYear: function(year) {
return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0)); return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0));

@ -777,8 +777,8 @@ class DateTimePickerSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriv
# Enter test data # Enter test data
member = models.Member.objects.create(name='Bob', birthdate=datetime(1984, 5, 15), gender='M') member = models.Member.objects.create(name='Bob', birthdate=datetime(1984, 5, 15), gender='M')
# Get month names translations for every locales # Get month name translations for every locale
month_string = 'January February March April May June July August September October November December' month_string = 'May'
path = os.path.join(os.path.dirname(import_module('django.contrib.admin').__file__), 'locale') path = os.path.join(os.path.dirname(import_module('django.contrib.admin').__file__), 'locale')
for language_code, language_name in settings.LANGUAGES: for language_code, language_name in settings.LANGUAGES:
try: try:
@ -786,12 +786,12 @@ class DateTimePickerSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriv
except IOError: except IOError:
continue continue
if month_string in catalog._catalog: if month_string in catalog._catalog:
month_names = catalog._catalog[month_string] month_name = catalog._catalog[month_string]
else: else:
month_names = month_string month_name = month_string
# Get the expected caption # Get the expected caption
may_translation = month_names.split(' ')[4] may_translation = month_name
expected_caption = '{0:s} {1:d}'.format(may_translation.upper(), 1984) expected_caption = '{0:s} {1:d}'.format(may_translation.upper(), 1984)
# Test with every locale # Test with every locale