Ticket #7980: i18n-formatting.2.diff

File i18n-formatting.2.diff, 142.2 KB (added by Jannis Leidel, 15 years ago)

Fixed issue with LANGUAGE_CODE of sublanguages

  • django/conf/global_settings.py

    diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
    index 828aef5..b2b6963 100644
    a b USE_I18N = True  
    103103LOCALE_PATHS = ()
    104104LANGUAGE_COOKIE_NAME = 'django_language'
    105105
     106# If you set this to True, Django will format dates, numbers and calendars
     107# according to user current locale
     108USE_FORMAT_I18N = False
     109
    106110# Not-necessarily-technical managers of the site. They get broken link
    107111# notifications and other various e-mails.
    108112MANAGERS = ADMINS
    FILE_UPLOAD_TEMP_DIR = None  
    262266# you'd pass directly to os.chmod; see http://docs.python.org/lib/os-file-dir.html.
    263267FILE_UPLOAD_PERMISSIONS = None
    264268
     269# Python module path where user will place custom format definition.
     270# The directory where this setting is pointing should contain subdirectories
     271# named as the locales, containing a formats.py file
     272# (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use)
     273FORMAT_MODULE_PATH = None
     274
    265275# Default formatting for date objects. See all available format strings here:
    266276# http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now
    267277DATE_FORMAT = 'N j, Y'
    YEAR_MONTH_FORMAT = 'F Y'  
    284294# http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now
    285295MONTH_DAY_FORMAT = 'F j'
    286296
     297# Default shortformatting for date objects. See all available format strings here:
     298# http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now
     299SHORT_DATE_FORMAT = 'm/d/Y'
     300
     301# Default short formatting for datetime objects.
     302# See all available format strings here:
     303# http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now
     304SHORT_DATETIME_FORMAT = 'm/d/Y P'
     305
     306# Default formats tried to parse dates from input boxes
     307# These formats are tried in the specified order
     308# See all available format string here:
     309# http://docs.python.org/library/datetime.html#strftime-behavior
     310# * Note that these format strings are different from the ones to display dates
     311DATE_INPUT_FORMATS = (
     312    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
     313    '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006'
     314    '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
     315    '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006'
     316    '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006'
     317)
     318
     319# Default formats tried to parse times from input boxes
     320# These formats are tried in the specified order
     321# See all available format string here:
     322# http://docs.python.org/library/datetime.html#strftime-behavior
     323# * Note that these format strings are different from the ones to display dates
     324TIME_INPUT_FORMATS = (
     325    '%H:%M:%S',     # '14:30:59'
     326    '%H:%M',        # '14:30'
     327)
     328
     329# Default formats tried to parse dates and times from input boxes
     330# These formats are tried in the specified order
     331# See all available format string here:
     332# http://docs.python.org/library/datetime.html#strftime-behavior
     333# * Note that these format strings are different from the ones to display dates
     334DATETIME_INPUT_FORMATS = (
     335    '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
     336    '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
     337    '%Y-%m-%d',              # '2006-10-25'
     338    '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
     339    '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
     340    '%m/%d/%Y',              # '10/25/2006'
     341    '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
     342    '%m/%d/%y %H:%M',        # '10/25/06 14:30'
     343    '%m/%d/%y',              # '10/25/06'
     344)
     345
     346# First day of week, to be used on calendars
     347# 0 means Sunday, 1 means Monday...
     348FIRST_DAY_OF_WEEK = 0
     349
     350# Decimal separator symbol
     351DECIMAL_SEPARATOR = '.'
     352
     353# Boolean that sets whether to add thousand separator when formatting numbers
     354USE_THOUSAND_SEPARATOR = False
     355
     356# Number of digits that will be togheter, when spliting them by THOUSAND_SEPARATOR
     357# 0 means no grouping, 3 means splitting by thousands...
     358NUMBER_GROUPING = 0
     359
     360# Thousand separator symbol
     361THOUSAND_SEPARATOR = ','
     362
    287363# Do you want to manage transactions manually?
    288364# Hint: you really don't!
    289365TRANSACTIONS_MANAGED = False
  • new file django/conf/locale/ar/formats.py

    diff --git a/django/conf/locale/__init__.py b/django/conf/locale/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ar/__init__.py b/django/conf/locale/ar/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ar/formats.py b/django/conf/locale/ar/formats.py
    new file mode 100644
    index 0000000..d8d627f
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F، Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd‏/m‏/Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/bg/formats.py

    diff --git a/django/conf/locale/bg/__init__.py b/django/conf/locale/bg/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/bg/formats.py b/django/conf/locale/bg/formats.py
    new file mode 100644
    index 0000000..045543a
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd.m.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/bn/formats.py

    diff --git a/django/conf/locale/bn/__init__.py b/django/conf/locale/bn/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/bn/formats.py b/django/conf/locale/bn/formats.py
    new file mode 100644
    index 0000000..46e5da9
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F, Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M, Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ca/formats.py

    diff --git a/django/conf/locale/ca/__init__.py b/django/conf/locale/ca/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ca/formats.py b/django/conf/locale/ca/formats.py
    new file mode 100644
    index 0000000..aebaea3
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j \de F \de Y'
     6TIME_FORMAT = 'G:i:s'
     7DATETIME_FORMAT = 'j \de F \de Y \\a \le\s G:i'
     8YEAR_MONTH_FORMAT = 'F \de\l Y'
     9MONTH_DAY_FORMAT = 'j \de F'
     10SHORT_DATE_FORMAT = 'd/m/Y'
     11SHORT_DATETIME_FORMAT = 'd/m/Y G:i'
     12FIRST_DAY_OF_WEEK = 1 # Monday
     13DATE_INPUT_FORMATS = (
     14    # '31/12/2009', '31/12/09'
     15    '%d/%m/%Y', '%d/%m/%y'
     16)
     17TIME_INPUT_FORMATS = (
     18    # '14:30:59', '14:30'
     19    '%H:%M:%S', '%H:%M'
     20)
     21DATETIME_INPUT_FORMATS = (
     22    '%d/%m/%Y %H:%M:%S',
     23    '%d/%m/%Y %H:%M',
     24    '%d/%m/%y %H:%M:%S',
     25    '%d/%m/%y %H:%M',
     26)
     27DECIMAL_SEPARATOR = ','
     28THOUSAND_SEPARATOR = '.'
     29NUMBER_GROUPING = 3
     30
  • new file django/conf/locale/cs/formats.py

    diff --git a/django/conf/locale/cs/__init__.py b/django/conf/locale/cs/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/cs/formats.py b/django/conf/locale/cs/formats.py
    new file mode 100644
    index 0000000..327e77e
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y'
     6TIME_FORMAT = 'G:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'j.n.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/cy/formats.py

    diff --git a/django/conf/locale/cy/__init__.py b/django/conf/locale/cy/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/cy/formats.py b/django/conf/locale/cy/formats.py
    new file mode 100644
    index 0000000..a58d81f
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10SHORT_DATE_FORMAT = 'j M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/da/formats.py

    diff --git a/django/conf/locale/da/__init__.py b/django/conf/locale/da/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/da/formats.py b/django/conf/locale/da/formats.py
    new file mode 100644
    index 0000000..9982014
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y'
     6TIME_FORMAT = 'H:i'
     7DATETIME_FORMAT = 'j. F Y H:i'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'd.m.Y'
     11SHORT_DATETIME_FORMAT = 'd.m.Y H:i'
     12FIRST_DAY_OF_WEEK = 1
     13DATE_INPUT_FORMATS = (
     14    '%d.%m.%Y',                         # '25.10.2006'
     15)
     16TIME_INPUT_FORMATS = (
     17    '%H:%M:%S',                         # '14:30:59'
     18    '%H:%M',                            # '14:30'
     19)
     20DATETIME_INPUT_FORMATS = (
     21    '%d.%m.%Y %H:%M:%S',                # '25.10.2006 14:30:59'
     22    '%d.%m.%Y %H:%M',                   # '25.10.2006 14:30'
     23)
     24DECIMAL_SEPARATOR = ','
     25THOUSAND_SEPARATOR = '.'
     26NUMBER_GROUPING = 3
  • new file django/conf/locale/de/formats.py

    diff --git a/django/conf/locale/de/__init__.py b/django/conf/locale/de/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/de/formats.py b/django/conf/locale/de/formats.py
    new file mode 100644
    index 0000000..89b5784
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y'
     6TIME_FORMAT = 'H:i:s'
     7DATETIME_FORMAT = 'j. F Y H:i:s'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'd.m.Y'
     11SHORT_DATETIME_FORMAT = 'd.m.Y H:i:s'
     12FIRST_DAY_OF_WEEK = 1 # Monday
     13DATE_INPUT_FORMATS = (
     14    '%d.%m.%Y', '%d.%m.%y',     # '25.10.2006', '25.10.06'
     15    '%Y-%m-%d', '%y-%m-%d',     # '2006-10-25', '06-10-25'
     16    '%d. %B %Y', '%d. %b. %Y',  # '25. October 2006', '25. Oct. 2006'
     17)
     18TIME_INPUT_FORMATS = (
     19    '%H:%M:%S', # '14:30:59'
     20    '%H:%M',    # '14:30'
     21)
     22DATETIME_INPUT_FORMATS = (
     23    '%d.%m.%Y %H:%M:%S',    # '25.10.2006 14:30:59'
     24    '%d.%m.%Y %H:%M',       # '25.10.2006 14:30'
     25    '%d.%m.%Y',             # '25.10.2006'
     26    '%Y-%m-%d %H:%M:%S',    # '2006-10-25 14:30:59'
     27    '%Y-%m-%d %H:%M',       # '2006-10-25 14:30'
     28    '%Y-%m-%d',             # '2006-10-25'
     29)
     30DECIMAL_SEPARATOR = ','
     31THOUSAND_SEPARATOR = '.'
     32NUMBER_GROUPING = 3
  • new file django/conf/locale/el/formats.py

    diff --git a/django/conf/locale/el/__init__.py b/django/conf/locale/el/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/el/formats.py b/django/conf/locale/el/formats.py
    new file mode 100644
    index 0000000..d476ab3
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/en/formats.py

    diff --git a/django/conf/locale/en/__init__.py b/django/conf/locale/en/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/en/formats.py b/django/conf/locale/en/formats.py
    new file mode 100644
    index 0000000..3a507cd
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'N j, Y'
     6TIME_FORMAT = 'P'
     7DATETIME_FORMAT = 'N j, Y, P'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'F j'
     10SHORT_DATE_FORMAT = 'm/d/Y'
     11SHORT_DATETIME_FORMAT = 'm/d/Y P'
     12FIRST_DAY_OF_WEEK = 0 # Sunday
     13DATE_INPUT_FORMATS = (
     14    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
     15    '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006'
     16    '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
     17    '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006'
     18    '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006'
     19)
     20TIME_INPUT_FORMATS = (
     21    '%H:%M:%S',     # '14:30:59'
     22    '%H:%M',        # '14:30'
     23)
     24DATETIME_INPUT_FORMATS = (
     25    '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
     26    '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
     27    '%Y-%m-%d',              # '2006-10-25'
     28    '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
     29    '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
     30    '%m/%d/%Y',              # '10/25/2006'
     31    '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
     32    '%m/%d/%y %H:%M',        # '10/25/06 14:30'
     33    '%m/%d/%y',              # '10/25/06'
     34)
     35DECIMAL_SEPARATOR = '.'
     36THOUSAND_SEPARATOR = ','
     37NUMBER_GROUPING = 3
     38
  • new file django/conf/locale/es/formats.py

    diff --git a/django/conf/locale/es/__init__.py b/django/conf/locale/es/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/es/formats.py b/django/conf/locale/es/formats.py
    new file mode 100644
    index 0000000..349810f
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j \de F \de Y'
     6TIME_FORMAT = 'H:i:s'
     7DATETIME_FORMAT = 'j \de F \de Y \a \l\a\s H:i'
     8YEAR_MONTH_FORMAT = 'F \de Y'
     9MONTH_DAY_FORMAT = 'j \de F'
     10SHORT_DATE_FORMAT = 'd/m/Y'
     11SHORT_DATETIME_FORMAT = 'd/m/Y H:i'
     12FIRST_DAY_OF_WEEK = 1 # Monday
     13DATE_INPUT_FORMATS = (
     14    # '31/12/2009', '31/12/09'
     15    '%d/%m/%Y', '%d/%m/%y'
     16)
     17TIME_INPUT_FORMATS = (
     18    # '14:30:59', '14:30'
     19    '%H:%M:%S', '%H:%M'
     20)
     21DATETIME_INPUT_FORMATS = (
     22    '%d/%m/%Y %H:%M:%S',
     23    '%d/%m/%Y %H:%M',
     24    '%d/%m/%y %H:%M:%S',
     25    '%d/%m/%y %H:%M',
     26)
     27DECIMAL_SEPARATOR = ','
     28THOUSAND_SEPARATOR = '.'
     29NUMBER_GROUPING = 3
     30
  • new file django/conf/locale/es_AR/formats.py

    diff --git a/django/conf/locale/es_AR/__init__.py b/django/conf/locale/es_AR/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/es_AR/formats.py b/django/conf/locale/es_AR/formats.py
    new file mode 100644
    index 0000000..6d71786
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5# DATE_FORMAT =
     6# TIME_FORMAT =
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10# SHORT_DATE_FORMAT =
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/et/formats.py

    diff --git a/django/conf/locale/et/__init__.py b/django/conf/locale/et/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/et/formats.py b/django/conf/locale/et/formats.py
    new file mode 100644
    index 0000000..b96420c
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'G:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd.m.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/eu/formats.py

    diff --git a/django/conf/locale/eu/__init__.py b/django/conf/locale/eu/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/eu/formats.py b/django/conf/locale/eu/formats.py
    new file mode 100644
    index 0000000..475f924
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'Yeko M\re\n d\a'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10SHORT_DATE_FORMAT = 'Y M j'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/fa/formats.py

    diff --git a/django/conf/locale/fa/__init__.py b/django/conf/locale/fa/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/fa/formats.py b/django/conf/locale/fa/formats.py
    new file mode 100644
    index 0000000..dc11281
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'G:i:s'
     7DATETIME_FORMAT = 'j F Y، ساعت G:i:s'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'Y/n/j'
     11SHORT_DATETIME_FORMAT = 'Y/n/j،‏ G:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/fi/formats.py

    diff --git a/django/conf/locale/fi/__init__.py b/django/conf/locale/fi/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/fi/formats.py b/django/conf/locale/fi/formats.py
    new file mode 100644
    index 0000000..670e268
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y'
     6TIME_FORMAT = 'G.i.s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'j.n.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/fr/formats.py

    diff --git a/django/conf/locale/fr/__init__.py b/django/conf/locale/fr/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/fr/formats.py b/django/conf/locale/fr/formats.py
    new file mode 100644
    index 0000000..1d670d7
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'H:i:s'
     7DATETIME_FORMAT = 'j F Y H:i:s'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11SHORT_DATETIME_FORMAT = 'j M Y H:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ga/formats.py

    diff --git a/django/conf/locale/ga/__init__.py b/django/conf/locale/ga/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ga/formats.py b/django/conf/locale/ga/formats.py
    new file mode 100644
    index 0000000..f177bb2
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/gl/formats.py

    diff --git a/django/conf/locale/gl/__init__.py b/django/conf/locale/gl/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/gl/formats.py b/django/conf/locale/gl/formats.py
    new file mode 100644
    index 0000000..e0a95d5
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M, Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/he/formats.py

    diff --git a/django/conf/locale/he/__init__.py b/django/conf/locale/he/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/he/formats.py b/django/conf/locale/he/formats.py
    new file mode 100644
    index 0000000..8d7c7f2
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j בF Y'
     6TIME_FORMAT = 'H:i:s'
     7DATETIME_FORMAT = 'j בF Y H:i:s'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j בF'
     10SHORT_DATE_FORMAT = 'd/m/Y'
     11SHORT_DATETIME_FORMAT = 'd/m/Y H:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/hi/formats.py

    diff --git a/django/conf/locale/hi/__init__.py b/django/conf/locale/hi/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/hi/formats.py b/django/conf/locale/hi/formats.py
    new file mode 100644
    index 0000000..6afa258
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd-m-Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/hr/formats.py

    diff --git a/django/conf/locale/hr/__init__.py b/django/conf/locale/hr/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/hr/formats.py b/django/conf/locale/hr/formats.py
    new file mode 100644
    index 0000000..62d1a7e
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y.'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y.'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'j.n.Y.'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/hu/formats.py

    diff --git a/django/conf/locale/hu/__init__.py b/django/conf/locale/hu/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/hu/formats.py b/django/conf/locale/hu/formats.py
    new file mode 100644
    index 0000000..6ee2db0
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'Y. F j.'
     6TIME_FORMAT = 'G:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'F j.'
     10SHORT_DATE_FORMAT = 'Y.m.d.'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/is/formats.py

    diff --git a/django/conf/locale/is/__init__.py b/django/conf/locale/is/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/is/formats.py b/django/conf/locale/is/formats.py
    new file mode 100644
    index 0000000..b6377db
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'j.n.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/it/formats.py

    diff --git a/django/conf/locale/it/__init__.py b/django/conf/locale/it/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/it/formats.py b/django/conf/locale/it/formats.py
    new file mode 100644
    index 0000000..fe86b5b
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'H.i.s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd/M/Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ja/formats.py

    diff --git a/django/conf/locale/ja/__init__.py b/django/conf/locale/ja/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ja/formats.py b/django/conf/locale/ja/formats.py
    new file mode 100644
    index 0000000..853056d
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'Y年n月j日'
     6TIME_FORMAT = 'G:i:s'
     7DATETIME_FORMAT = 'Y年n月j日G:i:s'
     8YEAR_MONTH_FORMAT = 'Y年n月'
     9MONTH_DAY_FORMAT = 'n月j日'
     10SHORT_DATE_FORMAT = 'Y/m/d'
     11SHORT_DATETIME_FORMAT = 'Y/m/d G:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ka/formats.py

    diff --git a/django/conf/locale/ka/__init__.py b/django/conf/locale/ka/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ka/formats.py b/django/conf/locale/ka/formats.py
    new file mode 100644
    index 0000000..665a73f
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'l, j F, Y'
     6TIME_FORMAT = 'h:i:s a'
     7DATETIME_FORMAT = 'j F, Y h:i:s a'
     8YEAR_MONTH_FORMAT = 'F, Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j.M.Y'
     11SHORT_DATETIME_FORMAT = 'j.M.Y H:i:s'
     12FIRST_DAY_OF_WEEK = 1 # (Monday)
     13DATE_INPUT_FORMATS = (
     14    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y',     # '2006-10-25', '10/25/2006', '10/25/06'
     15    '%d %b %Y', '%d %b, %Y', '%d %b. %Y',   # '25 Oct 2006', '25 Oct, 2006', '25 Oct. 2006'
     16    '%d %B %Y', '%d %B, %Y',                # '25 October 2006', '25 October, 2006'
     17    '%d.%m.%Y', '%d.%m.%y',                 # '25.10.2006', '25.10.06'
     18)
     19TIME_INPUT_FORMATS = (
     20    '%H:%M:%S',     # '14:30:59'
     21    '%H:%M',        # '14:30'
     22)
     23DATETIME_INPUT_FORMATS = (
     24    '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
     25    '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
     26    '%Y-%m-%d',              # '2006-10-25'
     27    '%d.%m.%Y %H:%M:%S',     # '25.10.2006 14:30:59'
     28    '%d.%m.%Y %H:%M',        # '25.10.2006 14:30'
     29    '%d.%m.%Y',              # '25.10.2006'
     30    '%d.%m.%y %H:%M:%S',     # '25.10.06 14:30:59'
     31    '%d.%m.%y %H:%M',        # '25.10.06 14:30'
     32    '%d.%m.%y',              # '25.10.06'
     33    '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
     34    '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
     35    '%m/%d/%Y',              # '10/25/2006'
     36    '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
     37    '%m/%d/%y %H:%M',        # '10/25/06 14:30'
     38    '%m/%d/%y',              # '10/25/06'
     39)
     40DECIMAL_SEPARATOR = '.'
     41THOUSAND_SEPARATOR = " "
     42NUMBER_GROUPING = 3
  • new file django/conf/locale/km/formats.py

    diff --git a/django/conf/locale/km/__init__.py b/django/conf/locale/km/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/km/formats.py b/django/conf/locale/km/formats.py
    new file mode 100644
    index 0000000..3736d57
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j ខែ F ឆ្នាំ Y'
     6TIME_FORMAT = 'G:i:s'
     7DATETIME_FORMAT = 'j ខែ F ឆ្នាំ Y, G:i:s'
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11SHORT_DATETIME_FORMAT = 'j M Y, G:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/kn/formats.py

    diff --git a/django/conf/locale/kn/__init__.py b/django/conf/locale/kn/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/kn/formats.py b/django/conf/locale/kn/formats.py
    new file mode 100644
    index 0000000..fa7a7b9
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'h:i:s A'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ko/formats.py

    diff --git a/django/conf/locale/ko/__init__.py b/django/conf/locale/ko/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ko/formats.py b/django/conf/locale/ko/formats.py
    new file mode 100644
    index 0000000..619047d
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'Y년 n월 j일'
     6TIME_FORMAT = 'A g:i:s'
     7DATETIME_FORMAT = 'Y년 n월 j일 g:i:s A'
     8YEAR_MONTH_FORMAT = 'Y년 F월'
     9MONTH_DAY_FORMAT = 'F월 j일'
     10SHORT_DATE_FORMAT = 'Y-n-j.'
     11SHORT_DATETIME_FORMAT = 'Y-n-j H:i'
     12# FIRST_DAY_OF_WEEK =
     13DATE_INPUT_FORMATS = (
     14    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
     15    '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006'
     16    '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
     17    '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006'
     18    '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006'
     19    '%Y년 %m월 %d일',                   # '2006년 10월 25일', with localized suffix.
     20)
     21TIME_INPUT_FORMATS = (
     22    '%H:%M:%S',     # '14:30:59'
     23    '%H:%M',        # '14:30'
     24    '%H시 %M분 %S초',   # '14시 30분 59초'
     25    '%H시 %M분',        # '14시 30분'
     26)
     27DATETIME_INPUT_FORMATS = (
     28    '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
     29    '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
     30    '%Y-%m-%d',              # '2006-10-25'
     31    '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
     32    '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
     33    '%m/%d/%Y',              # '10/25/2006'
     34    '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
     35    '%m/%d/%y %H:%M',        # '10/25/06 14:30'
     36    '%m/%d/%y',              # '10/25/06'
     37
     38    '%Y년 %m월 %d일 %H시 %M분 %S초',  # '2006년 10월 25일 14시 30분 59초'
     39    '%Y년 %m월 %d일 %H시 %M분',       # '2006년 10월 25일 14시 30분'
     40)
     41
     42DECIMAL_SEPARATOR = '.'
     43THOUSAND_SEPARATOR = ','
     44NUMBER_GROUPING = 3
  • new file django/conf/locale/lt/formats.py

    diff --git a/django/conf/locale/lt/__init__.py b/django/conf/locale/lt/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/lt/formats.py b/django/conf/locale/lt/formats.py
    new file mode 100644
    index 0000000..d9fb0c8
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'Y \m. F j \d.'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10SHORT_DATE_FORMAT = 'Y.m.d'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/lv/formats.py

    diff --git a/django/conf/locale/lv/__init__.py b/django/conf/locale/lv/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/lv/formats.py b/django/conf/locale/lv/formats.py
    new file mode 100644
    index 0000000..5dc211c
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'Y. \g\a\d\a j. F'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'Y. \g. F'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'Y. \g\a\d\a j. M'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/mk/formats.py

    diff --git a/django/conf/locale/mk/__init__.py b/django/conf/locale/mk/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/mk/formats.py b/django/conf/locale/mk/formats.py
    new file mode 100644
    index 0000000..746ac0e
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10SHORT_DATE_FORMAT = 'd.n.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/nl/formats.py

    diff --git a/django/conf/locale/nl/__init__.py b/django/conf/locale/nl/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/nl/formats.py b/django/conf/locale/nl/formats.py
    new file mode 100644
    index 0000000..dcef8c1
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'                   # '20 januari 2009'
     6TIME_FORMAT = 'H:i'                     # '15:23'
     7DATETIME_FORMAT = 'j F Y H:i'           # '20 januari 2009 15:23'
     8YEAR_MONTH_FORMAT = 'F Y'               # 'januari 2009'
     9MONTH_DAY_FORMAT = 'j F'                # '20 januari'
     10SHORT_DATE_FORMAT = 'j-n-Y'             # '20-1-2009'
     11SHORT_DATETIME_FORMAT = 'j-n-Y H:i'     # '20-1-2009 15:23'
     12FIRST_DAY_OF_WEEK = 1                   # Monday (in Dutch 'maandag')
     13DATE_INPUT_FORMATS = (
     14    '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20'
     15    '%d %b %Y', '%d %b %y',             # '20 jan 2009', '20 jan 09'
     16    '%d %B %Y', '%d %B %y',             # '20 januari 2009', '20 januari 09'
     17)
     18TIME_INPUT_FORMATS = (
     19    '%H:%M:%S',                         # '15:23:35'
     20    '%H.%M:%S',                         # '15.23:35'
     21    '%H.%M',                            # '15.23'
     22    '%H:%M',                            # '15:23'
     23)
     24DATETIME_INPUT_FORMATS = (
     25    # With time in %H:%M:%S :
     26    '%d-%m-%Y %H:%M:%S', '%d-%m-%y %H:%M:%S', '%Y-%m-%d %H:%M:%S',  # '20-01-2009 15:23:35', '20-01-09 15:23:35', '2009-01-20 15:23:35'
     27    '%d %b %Y %H:%M:%S', '%d %b %y %H:%M:%S',   # '20 jan 2009 15:23:35', '20 jan 09 15:23:35'
     28    '%d %B %Y %H:%M:%S', '%d %B %y %H:%M:%S',   # '20 januari 2009 15:23:35', '20 januari 2009 15:23:35'
     29    # With time in %H.%M:%S :
     30    '%d-%m-%Y %H.%M:%S', '%d-%m-%y %H.%M:%S',   # '20-01-2009 15.23:35', '20-01-09 15.23:35'
     31    '%d %b %Y %H.%M:%S', '%d %b %y %H.%M:%S',   # '20 jan 2009 15.23:35', '20 jan 09 15.23:35'
     32    '%d %B %Y %H.%M:%S', '%d %B %y %H.%M:%S',   # '20 januari 2009 15.23:35', '20 januari 2009 15.23:35'
     33    # With time in %H:%M :
     34    '%d-%m-%Y %H:%M', '%d-%m-%y %H:%M', '%Y-%m-%d %H:%M',   # '20-01-2009 15:23', '20-01-09 15:23', '2009-01-20 15:23'
     35    '%d %b %Y %H:%M', '%d %b %y %H:%M',         # '20 jan 2009 15:23', '20 jan 09 15:23'
     36    '%d %B %Y %H:%M', '%d %B %y %H:%M',         # '20 januari 2009 15:23', '20 januari 2009 15:23'
     37    # With time in %H.%M :
     38    '%d-%m-%Y %H.%M', '%d-%m-%y %H.%M',         # '20-01-2009 15.23', '20-01-09 15.23'
     39    '%d %b %Y %H.%M', '%d %b %y %H.%M',         # '20 jan 2009 15.23', '20 jan 09 15.23'
     40    '%d %B %Y %H.%M', '%d %B %y %H.%M',         # '20 januari 2009 15.23', '20 januari 2009 15.23'
     41    # Without time :
     42    '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d',         # '20-01-2009', '20-01-09', '2009-01-20'
     43    '%d %b %Y', '%d %b %y',                     # '20 jan 2009', '20 jan 09'
     44    '%d %B %Y', '%d %B %y',                     # '20 januari 2009', '20 januari 2009'
     45)
     46DECIMAL_SEPARATOR = ','
     47THOUSAND_SEPARATOR = '.'
     48NUMBER_GROUPING = 3
  • new file django/conf/locale/no/formats.py

    diff --git a/django/conf/locale/no/__init__.py b/django/conf/locale/no/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/no/formats.py b/django/conf/locale/no/formats.py
    new file mode 100644
    index 0000000..62ee886
    - +  
     1DATE_FORMAT = 'j. F Y'
     2TIME_FORMAT = 'H:i'
     3DATETIME_FORMAT = 'j. F Y H:i'
     4YEAR_MONTH_FORMAT = 'F Y'
     5MONTH_DAY_FORMAT = 'j. F'
     6SHORT_DATE_FORMAT = 'd.m.Y'
     7SHORT_DATETIME_FORMAT = 'd.m.Y H:i'
     8FIRST_DAY_OF_WEEK = 1 # Monday
     9DATE_INPUT_FORMATS = (
     10    '%Y-%m-%d', '%j.%m.%Y', '%j.%m.%y', # '2006-10-25', '25.10.2006', '25.10.06'
     11    '%Y-%m-%j',                         # '2006-10-25',
     12    '%j. %b %Y', '%j %b %Y',            # '25. okt 2006', '25 okt 2006'
     13    '%j. %b. %Y', '%j %b. %Y',          # '25. okt. 2006', '25 okt. 2006'
     14    '%j. %B %Y', '%j %B %Y',            # '25. oktober 2006', '25 oktober 2006'
     15)
     16TIME_INPUT_FORMATS = (
     17    '%H:%i:%S',     # '14:30:59'
     18    '%H:%i',     # '14:30'
     19)
     20DATETIME_INPUT_FORMATS = (
     21    '%Y-%m-%d %H:%i:%S',     # '2006-10-25 14:30:59'
     22    '%Y-%m-%d %H:%i',        # '2006-10-25 14:30'
     23    '%Y-%m-%d',              # '2006-10-25'
     24    '%Y-%m-%j',              # '2006-10-25'
     25    '%j.%m.%Y %H:%i:%S',     # '25.10.2006 14:30:59'
     26    '%j.%m.%Y %H:%i',        # '25.10.2006 14:30'
     27    '%j.%m.%Y',              # '25.10.2006'
     28    '%j.%m.%y %H:%i:%S',     # '25.10.06 14:30:59'
     29    '%j.%m.%y %H:%i',        # '25.10.06 14:30'
     30    '%j.%m.%y',              # '25.10.06'
     31)
     32DECIMAL_SEPARATOR = ','
     33THOUSAND_SEPARATOR = ' '
     34NUMBER_GROUPING = 3
  • new file django/conf/locale/pl/formats.py

    diff --git a/django/conf/locale/pl/__init__.py b/django/conf/locale/pl/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/pl/formats.py b/django/conf/locale/pl/formats.py
    new file mode 100644
    index 0000000..860a4a8
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd-m-Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/pt/formats.py

    diff --git a/django/conf/locale/pt/__init__.py b/django/conf/locale/pt/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/pt/formats.py b/django/conf/locale/pt/formats.py
    new file mode 100644
    index 0000000..053a48a
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j \de F \de Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F \de Y'
     9MONTH_DAY_FORMAT = 'j \de F'
     10SHORT_DATE_FORMAT = 'd/m/Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/pt_BR/formats.py

    diff --git a/django/conf/locale/pt_BR/__init__.py b/django/conf/locale/pt_BR/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/pt_BR/formats.py b/django/conf/locale/pt_BR/formats.py
    new file mode 100644
    index 0000000..f30d5c4
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j \\de N \\de Y'
     6TIME_FORMAT = 'H:i'
     7DATETIME_FORMAT = 'j \\de N \\de Y à\\s H:i'
     8YEAR_MONTH_FORMAT = 'F \\de Y'
     9MONTH_DAY_FORMAT = 'j \\de F'
     10SHORT_DATE_FORMAT = 'd/m/Y'
     11SHORT_DATETIME_FORMAT = 'd/m/Y H:i'
     12FIRST_DAY_OF_WEEK = 0  # Sunday
     13DATE_INPUT_FORMATS = (
     14    '%Y-%m-%d', '%d/%m/%Y', '%d/%m/%y', # '2006-10-25', '25/10/2006', '25/10/06'
     15    '%d de %b de %Y', '%d de %b, %Y',   # '25 de Out de 2006', '25 Out, 2006'
     16    '%d de %B de %Y', '%d de %B, %Y',   # '25 de Outubro de 2006', '25 de Outubro, 2006'
     17)
     18TIME_INPUT_FORMATS = (
     19    '%H:%M:%S',     # '14:30:59'
     20    '%H:%M',        # '14:30'
     21)
     22DATETIME_INPUT_FORMATS = (
     23    '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
     24    '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
     25    '%Y-%m-%d',              # '2006-10-25'
     26    '%d/%m/%Y %H:%M:%S',     # '25/10/2006 14:30:59'
     27    '%d/%m/%Y %H:%M',        # '25/10/2006 14:30'
     28    '%d/%m/%Y',              # '25/10/2006'
     29    '%d/%m/%y %H:%M:%S',     # '25/10/06 14:30:59'
     30    '%d/%m/%y %H:%M',        # '25/10/06 14:30'
     31    '%d/%m/%y',              # '25/10/06'
     32)
     33DECIMAL_SEPARATOR = ','
     34THOUSAND_SEPARATOR = '.'
     35NUMBER_GROUPING = 3
  • new file django/conf/locale/ro/formats.py

    diff --git a/django/conf/locale/ro/__init__.py b/django/conf/locale/ro/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ro/formats.py b/django/conf/locale/ro/formats.py
    new file mode 100644
    index 0000000..6d6e800
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'H:i:s'
     7DATETIME_FORMAT = 'j F Y, H:i:s'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd.m.Y'
     11SHORT_DATETIME_FORMAT = 'd.m.Y, H:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ru/formats.py

    diff --git a/django/conf/locale/ru/__init__.py b/django/conf/locale/ru/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ru/formats.py b/django/conf/locale/ru/formats.py
    new file mode 100644
    index 0000000..9a9ee96
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y г.'
     6TIME_FORMAT = 'G:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'd.m.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/sk/formats.py

    diff --git a/django/conf/locale/sk/__init__.py b/django/conf/locale/sk/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/sk/formats.py b/django/conf/locale/sk/formats.py
    new file mode 100644
    index 0000000..1bc3549
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j. F Y'
     6TIME_FORMAT = 'G:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'j.n.Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/sl/formats.py

    diff --git a/django/conf/locale/sl/__init__.py b/django/conf/locale/sl/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/sl/formats.py b/django/conf/locale/sl/formats.py
    new file mode 100644
    index 0000000..4007f10
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd. F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j. F'
     10SHORT_DATE_FORMAT = 'j. M. Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/sr/formats.py

    diff --git a/django/conf/locale/sr/__init__.py b/django/conf/locale/sr/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/sr/formats.py b/django/conf/locale/sr/formats.py
    new file mode 100644
    index 0000000..b1aaa77
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd. F Y.'
     6TIME_FORMAT = 'H.i.s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'Y F'
     9MONTH_DAY_FORMAT = 'F j.'
     10SHORT_DATE_FORMAT = 'd.m.Y.'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/sr_Latn/formats.py

    diff --git a/django/conf/locale/sr_Latn/__init__.py b/django/conf/locale/sr_Latn/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/sr_Latn/formats.py b/django/conf/locale/sr_Latn/formats.py
    new file mode 100644
    index 0000000..6d71786
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5# DATE_FORMAT =
     6# TIME_FORMAT =
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10# SHORT_DATE_FORMAT =
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/sv/formats.py

    diff --git a/django/conf/locale/sv/__init__.py b/django/conf/locale/sv/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/sv/formats.py b/django/conf/locale/sv/formats.py
    new file mode 100644
    index 0000000..df4e633
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'H.i.s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'Y F'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/ta/formats.py

    diff --git a/django/conf/locale/ta/__init__.py b/django/conf/locale/ta/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/ta/formats.py b/django/conf/locale/ta/formats.py
    new file mode 100644
    index 0000000..69fa17d
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F, Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M, Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/te/formats.py

    diff --git a/django/conf/locale/te/__init__.py b/django/conf/locale/te/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/te/formats.py b/django/conf/locale/te/formats.py
    new file mode 100644
    index 0000000..e805872
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'g:i:s A'
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/th/formats.py

    diff --git a/django/conf/locale/th/__init__.py b/django/conf/locale/th/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/th/formats.py b/django/conf/locale/th/formats.py
    new file mode 100644
    index 0000000..7091dc6
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y'
     6TIME_FORMAT = 'G:i:s'
     7DATETIME_FORMAT = 'j F Y, G:i:s'
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11SHORT_DATETIME_FORMAT = 'j M Y, G:i:s'
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = '.'
     17THOUSAND_SEPARATOR = ','
     18# NUMBER_GROUPING =
  • new file django/conf/locale/tr/formats.py

    diff --git a/django/conf/locale/tr/__init__.py b/django/conf/locale/tr/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/tr/formats.py b/django/conf/locale/tr/formats.py
    new file mode 100644
    index 0000000..b978788
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'd F Y'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'd F'
     10SHORT_DATE_FORMAT = 'd M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = '.'
     18# NUMBER_GROUPING =
  • new file django/conf/locale/uk/formats.py

    diff --git a/django/conf/locale/uk/__init__.py b/django/conf/locale/uk/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/uk/formats.py b/django/conf/locale/uk/formats.py
    new file mode 100644
    index 0000000..8e41bf0
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5DATE_FORMAT = 'j F Y р.'
     6TIME_FORMAT = 'H:i:s'
     7# DATETIME_FORMAT =
     8YEAR_MONTH_FORMAT = 'F Y'
     9MONTH_DAY_FORMAT = 'j F'
     10SHORT_DATE_FORMAT = 'j M Y'
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16DECIMAL_SEPARATOR = ','
     17THOUSAND_SEPARATOR = ' '
     18# NUMBER_GROUPING =
  • new file django/conf/locale/zh_CN/formats.py

    diff --git a/django/conf/locale/zh_CN/__init__.py b/django/conf/locale/zh_CN/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/zh_CN/formats.py b/django/conf/locale/zh_CN/formats.py
    new file mode 100644
    index 0000000..6d71786
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5# DATE_FORMAT =
     6# TIME_FORMAT =
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10# SHORT_DATE_FORMAT =
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • new file django/conf/locale/zh_TW/formats.py

    diff --git a/django/conf/locale/zh_TW/__init__.py b/django/conf/locale/zh_TW/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/conf/locale/zh_TW/formats.py b/django/conf/locale/zh_TW/formats.py
    new file mode 100644
    index 0000000..6d71786
    - +  
     1# -*- encoding: utf-8 -*-
     2# This file is distributed under the same license as the Django package.
     3#
     4
     5# DATE_FORMAT =
     6# TIME_FORMAT =
     7# DATETIME_FORMAT =
     8# YEAR_MONTH_FORMAT =
     9# MONTH_DAY_FORMAT =
     10# SHORT_DATE_FORMAT =
     11# SHORT_DATETIME_FORMAT =
     12# FIRST_DAY_OF_WEEK =
     13# DATE_INPUT_FORMATS =
     14# TIME_INPUT_FORMATS =
     15# DATETIME_INPUT_FORMATS =
     16# DECIMAL_SEPARATOR =
     17# THOUSAND_SEPARATOR =
     18# NUMBER_GROUPING =
  • django/contrib/admin/media/js/calendar.js

    diff --git a/django/contrib/admin/media/js/calendar.js b/django/contrib/admin/media/js/calendar.js
    index 9035176..3f57145 100644
    a b function quickElement() {  
    2525var CalendarNamespace = {
    2626    monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
    2727    daysOfWeek: gettext('S M T W T F S').split(' '),
     28    firstDayOfWeek: parseInt(gettext('FIRST_DAY_OF_WEEK')),
    2829    isLeapYear: function(year) {
    2930        return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0));
    3031    },
    var CalendarNamespace = {  
    5657        // Draw days-of-week header
    5758        var tableRow = quickElement('tr', tableBody);
    5859        for (var i = 0; i < 7; i++) {
    59             quickElement('th', tableRow, CalendarNamespace.daysOfWeek[i]);
     60            quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
    6061        }
    6162
    62         var startingPos = new Date(year, month-1, 1).getDay();
     63        var startingPos = new Date(year, month-1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
    6364        var days = CalendarNamespace.getDaysInMonth(month, year);
    6465
    6566        // Draw blanks before first of month
  • django/contrib/admin/templates/admin/object_history.html

    diff --git a/django/contrib/admin/templates/admin/object_history.html b/django/contrib/admin/templates/admin/object_history.html
    index 38b1c34..9e6223a 100644
    a b  
    2727        <tbody>
    2828        {% for action in action_list %}
    2929        <tr>
    30             <th scope="row">{{ action.action_time|date:_("DATETIME_FORMAT") }}</th>
     30            <th scope="row">{{ action.action_time|date }}</th>
    3131            <td>{{ action.user.username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td>
    3232            <td>{{ action.change_message }}</td>
    3333        </tr>
  • django/contrib/admin/templatetags/admin_list.py

    diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
    index 5a02ab0..cd05957 100644
    a b from django.contrib.admin.views.main import ALL_VAR, EMPTY_CHANGELIST_VALUE  
    33from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR
    44from django.core.exceptions import ObjectDoesNotExist
    55from django.db import models
    6 from django.utils import dateformat
     6from django.utils import formats
    77from django.utils.html import escape, conditional_escape
    88from django.utils.text import capfirst
    99from django.utils.safestring import mark_safe
    10 from django.utils.translation import get_date_formats, get_partial_date_formats, ugettext as _
     10from django.utils.translation import ugettext as _
    1111from django.utils.encoding import smart_unicode, smart_str, force_unicode
    1212from django.template import Library
    1313import datetime
    def items_for_result(cl, result, form):  
    189189            # Dates and times are special: They're formatted in a certain way.
    190190            elif isinstance(f, models.DateField) or isinstance(f, models.TimeField):
    191191                if field_val:
    192                     (date_format, datetime_format, time_format) = get_date_formats()
    193                     if isinstance(f, models.DateTimeField):
    194                         result_repr = capfirst(dateformat.format(field_val, datetime_format))
    195                     elif isinstance(f, models.TimeField):
    196                         result_repr = capfirst(dateformat.time_format(field_val, time_format))
    197                     else:
    198                         result_repr = capfirst(dateformat.format(field_val, date_format))
     192                    result_repr = formats.localize(field_val)
     193                else:
     194                    result_repr = EMPTY_CHANGELIST_VALUE
     195            elif isinstance(f, models.DecimalField):
     196                if field_val:
     197                    result_repr = formats.number_format(field_val, f.decimal_places)
     198                else:
     199                    result_repr = EMPTY_CHANGELIST_VALUE
     200                row_class = ' class="nowrap"'
     201            elif isinstance(f, models.FloatField):
     202                if field_val:
     203                    result_repr = formats.number_format(field_val)
    199204                else:
    200205                    result_repr = EMPTY_CHANGELIST_VALUE
    201206                row_class = ' class="nowrap"'
    202207            # Booleans are special: We use images.
    203208            elif isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField):
    204209                result_repr = _boolean_icon(field_val)
    205             # DecimalFields are special: Zero-pad the decimals.
    206             elif isinstance(f, models.DecimalField):
    207                 if field_val is not None:
    208                     result_repr = ('%%.%sf' % f.decimal_places) % field_val
    209                 else:
    210                     result_repr = EMPTY_CHANGELIST_VALUE
    211210            # Fields with choices are special: Use the representation
    212211            # of the choice.
    213212            elif f.flatchoices:
    def date_hierarchy(cl):  
    268267        year_lookup = cl.params.get(year_field)
    269268        month_lookup = cl.params.get(month_field)
    270269        day_lookup = cl.params.get(day_field)
    271         year_month_format, month_day_format = get_partial_date_formats()
    272270
    273271        link = lambda d: cl.get_query_string(d, [field_generic])
    274272
    def date_hierarchy(cl):  
    278276                'show': True,
    279277                'back': {
    280278                    'link': link({year_field: year_lookup, month_field: month_lookup}),
    281                     'title': dateformat.format(day, year_month_format)
     279                    'title': capfirst(formats.date_format(day, 'YEAR_MONTH_FORMAT'))
    282280                },
    283                 'choices': [{'title': dateformat.format(day, month_day_format)}]
     281                'choices': [{'title': capfirst(formats.date_format(day, 'MONTH_DAY_FORMAT'))}]
    284282            }
    285283        elif year_lookup and month_lookup:
    286284            days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day')
    def date_hierarchy(cl):  
    292290                },
    293291                'choices': [{
    294292                    'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),
    295                     'title': dateformat.format(day, month_day_format)
     293                    'title': capfirst(formats.date_format(day, 'MONTH_DAY_FORMAT'))
    296294                } for day in days]
    297295            }
    298296        elif year_lookup:
    def date_hierarchy(cl):  
    305303                },
    306304                'choices': [{
    307305                    'link': link({year_field: year_lookup, month_field: month.month}),
    308                     'title': dateformat.format(month, year_month_format)
     306                    'title': capfirst(formats.date_format(month, 'YEAR_MONTH_FORMAT'))
    309307                } for month in months]
    310308            }
    311309        else:
  • django/contrib/databrowse/datastructures.py

    diff --git a/django/contrib/databrowse/datastructures.py b/django/contrib/databrowse/datastructures.py
    index 5fdbdbe..369f825 100644
    a b convenience functionality and permalink functions for the databrowse app.  
    44"""
    55
    66from django.db import models
    7 from django.utils import dateformat
     7from django.utils import formats
    88from django.utils.text import capfirst
    9 from django.utils.translation import get_date_formats
    109from django.utils.encoding import smart_unicode, smart_str, iri_to_uri
    1110from django.utils.safestring import mark_safe
    1211from django.db.models.query import QuerySet
    class EasyInstanceField(object):  
    156155            objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE)
    157156        elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField):
    158157            if self.raw_value:
    159                 date_format, datetime_format, time_format = get_date_formats()
    160158                if isinstance(self.field, models.DateTimeField):
    161                     objs = capfirst(dateformat.format(self.raw_value, datetime_format))
     159                    objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT'))
    162160                elif isinstance(self.field, models.TimeField):
    163                     objs = capfirst(dateformat.time_format(self.raw_value, time_format))
     161                    objs = capfirst(formats.date_format(self.raw_value, 'TIME_FORMAT'))
    164162                else:
    165                     objs = capfirst(dateformat.format(self.raw_value, date_format))
     163                    objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT'))
    166164            else:
    167165                objs = EMPTY_VALUE
    168166        elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField):
  • new file django/core/management/commands/importcldr.py

    diff --git a/django/core/management/commands/importcldr.py b/django/core/management/commands/importcldr.py
    new file mode 100644
    index 0000000..c4a13e6
    - +  
     1import sys
     2import os
     3import re
     4from optparse import make_option, OptionParser
     5
     6from django.core.management.base import LabelCommand, CommandError
     7
     8try:
     9    from lxml import etree
     10except ImportError:
     11    raise CommandError('You need to install `python-lxml` to run this script')
     12
     13FORMATS_FILE_NAME = 'formats.py'
     14FORMATS_FILE_HEADER = '''# -*- encoding: utf-8 -*-
     15# This file is distributed under the same license as the Django package.
     16#
     17
     18'''
     19
     20def quote(nodes, name,  locale, previous):
     21    if len(nodes):
     22        return "'%s'" % unicode(nodes[0].text).replace("'", "\\'")
     23    else:
     24        return None
     25
     26def convert_time(nodes, name,  locale, previous):
     27    SPECIAL_CHARS = ('a', 'A', 'b', 'B', 'd', 'D', 'f', 'F', 'g', 'G', 'h',
     28        'H', 'i', 'I', 'j', 'l', 'L', 'm', 'M', 'n', 'N', 'O', 'P', 'r',
     29        's', 'S', 't', 'T', 'U', 'w', 'W', 'y', 'Y', 'z', 'Z')
     30    FORMAT_STR_MAP = ( # not using a dict, because we have to apply formats in order
     31        ('dd', 'd'),
     32        ('d', 'j'),
     33        ('MMMM', 'F'),
     34        ('MMM', 'M'),
     35        ('MM', 'm'),
     36        ('M', 'n'),
     37        ('yyyy', 'Y'),
     38        ('yy', 'y'),
     39        ('y', 'Y'),
     40        ('hh', 'h'),
     41        ('h', 'g'),
     42        ('HH', 'H'),
     43        ('H', 'G'),
     44        ('mm', 'i'),
     45        ('ss', 's'),
     46        ('a', 'A'),
     47        ('LLLL', 'F'),
     48    )
     49    if len(nodes):
     50        original = nodes[0].text
     51        result = ''
     52        for cnt, segment in enumerate(original.split("'")):
     53            if cnt % 2:
     54                for char in SPECIAL_CHARS:
     55                    segment = segment.replace(char, '\\%s' % char)
     56                result += segment
     57            else:
     58                while segment:
     59                    found = False
     60                    for src, dst in FORMAT_STR_MAP:
     61                        if segment[0:len(src)] == src:
     62                            result += dst
     63                            segment = segment[len(src):]
     64                            found = True
     65                            break
     66                    if not found:
     67                        result += segment[0]
     68                        segment = segment[1:]
     69
     70        return "'%s'" % result
     71    else:
     72        return None
     73
     74def datetime(nodes, name, locale, previous):
     75    result = None
     76    if len(nodes) and 'DATE_FORMAT' in previous and 'TIME_FORMAT' in previous:
     77        result = nodes[0].text
     78        result = result.replace('{0}', previous['TIME_FORMAT'][1:-1])
     79        if name == 'SHORT_DATETIME_FORMAT' and 'SHORT_DATE_FORMAT' in previous:
     80            result = result.replace('{1}', previous['SHORT_DATE_FORMAT'][1:-1])
     81        else:
     82            result = result.replace('{1}', previous['DATE_FORMAT'][1:-1])
     83    if result:
     84        return "'%s'" % result
     85    else:
     86        return None
     87
     88FORMATS_MAP = [
     89    {
     90        'name': 'DATE_FORMAT',
     91        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     92        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateFormats/dateFormatLength[@type='long']/dateFormat/pattern",
     93        'conversion': convert_time,
     94    },
     95    {
     96        'name': 'TIME_FORMAT',
     97        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     98        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/timeFormats/timeFormatLength[@type='medium']/timeFormat/pattern",
     99        'conversion': convert_time,
     100    },
     101    {
     102        'name': 'DATETIME_FORMAT',
     103        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     104        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/dateTimeFormatLength[@type='long']/dateTimeFormat/pattern",
     105        'conversion': datetime,
     106    },
     107    {
     108        'name': 'YEAR_MONTH_FORMAT',
     109        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     110        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[@id='yMMMM']",
     111        'conversion': convert_time,
     112    },
     113    {
     114        'name': 'MONTH_DAY_FORMAT',
     115        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     116        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[@id='MMMMd']",
     117        'conversion': convert_time,
     118    },
     119    {
     120        'name': 'SHORT_DATE_FORMAT',
     121        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     122        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateFormats/dateFormatLength[@type='medium']/dateFormat/pattern",
     123        'conversion': convert_time,
     124    },
     125    {
     126        'name': 'SHORT_DATETIME_FORMAT',
     127        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     128        'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/dateTimeFormatLength[@type='short']/dateTimeFormat/pattern",
     129        'conversion': datetime,
     130    },
     131    {'name': 'FIRST_DAY_OF_WEEK'},
     132    {'name': 'DATE_INPUT_FORMATS'},
     133    {'name': 'TIME_INPUT_FORMATS'},
     134    {'name': 'DATETIME_INPUT_FORMATS'},
     135    {
     136        'name': 'DECIMAL_SEPARATOR',
     137        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     138        'pattern': "/ldml/numbers/symbols/decimal",
     139        'conversion': quote,
     140    },
     141    {
     142        'name': 'THOUSAND_SEPARATOR',
     143        'file': os.path.join('common', 'main', '%(locale)s.xml'),
     144        'pattern': "/ldml/numbers/symbols/group",
     145        'conversion': quote,
     146    },
     147    {'name': 'NUMBER_GROUPING'},
     148]
     149"""
     150"""
     151
     152def get_locales(django_locale_dir, locale=None):
     153    if locale:
     154        yield locale
     155    else:
     156        locale_re = re.compile('[a-z]{2}(_[A-Z]{2})?')
     157        for locale in os.listdir(django_locale_dir):
     158            if locale_re.match(locale):
     159                yield locale
     160
     161def import_cldr(cldr_dir, locale=None, overwrite=False):
     162    """
     163    For every locale defined in Django, get from the CLDR locale file all
     164    settings defined in output_structure, and write the result to the
     165    locale directories on Django.
     166    """
     167    if not os.path.isdir(cldr_dir):
     168        raise Exception, "Specified CLDR directory '%s' does not exist" % cldr_dir
     169
     170    import django
     171    django_locale_dir = os.path.join(os.path.dirname(django.__file__), 'conf', 'locale')
     172
     173    for locale in get_locales(django_locale_dir, locale):
     174        output_filename = os.path.join(django_locale_dir, locale, FORMATS_FILE_NAME)
     175        if os.path.isfile(output_filename) and not overwrite:
     176            print "'%s' locale already exists. Skipping" % locale
     177        else:
     178            result = {}
     179            output_file = open(output_filename, 'w')
     180            output_file.write(FORMATS_FILE_HEADER)
     181            for format in FORMATS_MAP:
     182                if 'file' in format:
     183                    cldr_file = os.path.join(cldr_dir, format['file'] % dict(locale=locale))
     184                    tree = etree.parse(cldr_file) # TODO: error control
     185                    try:
     186                        original_value = tree.xpath(format['pattern'])
     187                    except IndexError:
     188                        output_file.write('# %s = \n' % (format['name']))
     189                    else:
     190                        value = format['conversion'](original_value, format['name'], locale, result)
     191                        if value:
     192                            output_file.write('%s = %s\n' % (format['name'], value.encode('utf8')))
     193                            result[format['name']] = value
     194                        else:
     195                            output_file.write('# %s = \n' % (format['name']))
     196                else:
     197                    output_file.write('# %s = \n' % (format['name']))
     198            output_file.close()
     199
     200            init_filename = os.path.join(django_locale_dir, locale, '__init__.py')
     201            open(init_filename, 'a').close()
     202
     203class Command(LabelCommand):
     204    option_list = LabelCommand.option_list + (
     205        make_option('--locale', '-l', dest='locale',
     206            help='The locale to process. Default is to process all.'),
     207    ) + (
     208        make_option('--overwite', '-o', action='store_true', dest='overwrite',
     209            help='Wheter to overwrite format definitions of locales that already have one.'),
     210    )
     211    help = 'Creates format definition files for locales, importing data from the CLDR.'
     212    args = '[cldrpath]'
     213    label = 'CLDR path'
     214    requires_model_validation = False
     215    can_import_settings = False
     216
     217    def handle_label(self, cldrpath, **options):
     218        locale = options.get('locale')
     219        overwrite = options.get('overwrite')
     220        import_cldr(cldrpath, locale, overwrite)
     221
  • django/forms/extras/widgets.py

    diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py
    index e36b8a1..04ad24d 100644
    a b import re  
    88from django.forms.widgets import Widget, Select
    99from django.utils.dates import MONTHS
    1010from django.utils.safestring import mark_safe
     11from django.utils.formats import getformat
     12from django.conf import settings
    1113
    1214__all__ = ('SelectDateWidget',)
    1315
    class SelectDateWidget(Widget):  
    4547                if match:
    4648                    year_val, month_val, day_val = [int(v) for v in match.groups()]
    4749
    48         output = []
    49 
    50         if 'id' in self.attrs:
    51             id_ = self.attrs['id']
    52         else:
    53             id_ = 'id_%s' % name
    54 
    55         month_choices = MONTHS.items()
    56         if not (self.required and value):
    57             month_choices.append(self.none_value)
    58         month_choices.sort()
    59         local_attrs = self.build_attrs(id=self.month_field % id_)
    60         s = Select(choices=month_choices)
    61         select_html = s.render(self.month_field % name, month_val, local_attrs)
    62         output.append(select_html)
    63 
    64         day_choices = [(i, i) for i in range(1, 32)]
    65         if not (self.required and value):
    66             day_choices.insert(0, self.none_value)
    67         local_attrs['id'] = self.day_field % id_
    68         s = Select(choices=day_choices)
    69         select_html = s.render(self.day_field % name, day_val, local_attrs)
    70         output.append(select_html)
    71 
    72         year_choices = [(i, i) for i in self.years]
    73         if not (self.required and value):
    74             year_choices.insert(0, self.none_value)
    75         local_attrs['id'] = self.year_field % id_
    76         s = Select(choices=year_choices)
    77         select_html = s.render(self.year_field % name, year_val, local_attrs)
    78         output.append(select_html)
     50        choices = [(i, i) for i in self.years]
     51        year_html = self.create_select(name, self.year_field, value, year_val, choices)
     52        choices = MONTHS.items()
     53        month_html = self.create_select(name, self.month_field, value, month_val, choices)
     54        choices = [(i, i) for i in range(1, 32)]
     55        day_html = self.create_select(name, self.day_field, value, day_val,  choices)
    7956
     57        format = getformat('DATE_FORMAT')
     58        escaped = False
     59        output = []
     60        for char in format:
     61            if escaped:
     62                escaped = False
     63            elif char == '\\':
     64                escaped = True
     65            elif char in 'Yy':
     66                output.append(year_html)
     67            elif char in 'bFMmNn':
     68                output.append(month_html)
     69            elif char in 'dj':
     70                output.append(day_html)
    8071        return mark_safe(u'\n'.join(output))
    8172
    8273    def id_for_label(self, id_):
    class SelectDateWidget(Widget):  
    9081        if y == m == d == "0":
    9182            return None
    9283        if y and m and d:
    93             return '%s-%s-%s' % (y, m, d)
     84            if settings.USE_FORMAT_I18N:
     85                input_format = getformat('DATE_INPUT_FORMATS')[0]
     86                try:
     87                    date_value = datetime.date(int(y), int(m), int(d))
     88                except ValueError:
     89                    pass
     90                else:
     91                    return date_value.strftime(input_format)
     92            else:
     93                return '%s-%s-%s' % (y, m, d)
    9494        return data.get(name, None)
     95
     96    def create_select(self, name, field, value, val, choices):
     97        if 'id' in self.attrs:
     98            id_ = self.attrs['id']
     99        else:
     100            id_ = 'id_%s' % name
     101        if not (self.required and value):
     102            choices.insert(0, self.none_value)
     103        local_attrs = self.build_attrs(id=field % id_)
     104        s = Select(choices=choices)
     105        select_html = s.render(field % name, val, local_attrs)
     106        return select_html
     107
  • django/forms/fields.py

    diff --git a/django/forms/fields.py b/django/forms/fields.py
    index 0aef355..6f8c222 100644
    a b except NameError:  
    2626import django.core.exceptions
    2727from django.utils.translation import ugettext_lazy as _
    2828from django.utils.encoding import smart_unicode, smart_str
     29from django.utils.formats import getformat
    2930
    3031from util import ErrorList, ValidationError
    3132from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget
    3233
    3334__all__ = (
    3435    'Field', 'CharField', 'IntegerField',
    35     'DEFAULT_DATE_INPUT_FORMATS', 'DateField',
    36     'DEFAULT_TIME_INPUT_FORMATS', 'TimeField',
    37     'DEFAULT_DATETIME_INPUT_FORMATS', 'DateTimeField', 'TimeField',
     36    'DateField', 'TimeField', 'DateTimeField', 'TimeField',
    3837    'RegexField', 'EmailField', 'FileField', 'ImageField', 'URLField',
    3938    'BooleanField', 'NullBooleanField', 'ChoiceField', 'MultipleChoiceField',
    4039    'ComboField', 'MultiValueField', 'FloatField', 'DecimalField',
    class FloatField(Field):  
    209208        if not self.required and value in EMPTY_VALUES:
    210209            return None
    211210        try:
    212             value = float(value)
     211            # We always accept dot as decimal separator
     212            if isinstance(value, str) or isinstance(value, unicode):
     213                value = float(value.replace(getformat('DECIMAL_SEPARATOR'), '.'))
    213214        except (ValueError, TypeError):
    214215            raise ValidationError(self.error_messages['invalid'])
    215216        if self.max_value is not None and value > self.max_value:
    class DecimalField(Field):  
    245246            return None
    246247        value = smart_str(value).strip()
    247248        try:
    248             value = Decimal(value)
     249            # We always accept dot as decimal separator
     250            if isinstance(value, str) or isinstance(value, unicode):
     251                value = Decimal(value.replace(getformat('DECIMAL_SEPARATOR'), '.'))
    249252        except DecimalException:
    250253            raise ValidationError(self.error_messages['invalid'])
    251254
    class DecimalField(Field):  
    273276            raise ValidationError(self.error_messages['max_whole_digits'] % (self.max_digits - self.decimal_places))
    274277        return value
    275278
    276 DEFAULT_DATE_INPUT_FORMATS = (
    277     '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
    278     '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006'
    279     '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
    280     '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006'
    281     '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006'
    282 )
    283 
    284279class DateField(Field):
    285280    widget = DateInput
    286281    default_error_messages = {
    class DateField(Field):  
    289284
    290285    def __init__(self, input_formats=None, *args, **kwargs):
    291286        super(DateField, self).__init__(*args, **kwargs)
    292         self.input_formats = input_formats or DEFAULT_DATE_INPUT_FORMATS
     287        self.input_formats = input_formats
    293288
    294289    def clean(self, value):
    295290        """
    class DateField(Field):  
    303298            return value.date()
    304299        if isinstance(value, datetime.date):
    305300            return value
    306         for format in self.input_formats:
     301        for format in self.input_formats or getformat('DATE_INPUT_FORMATS'):
    307302            try:
    308303                return datetime.date(*time.strptime(value, format)[:3])
    309304            except ValueError:
    310305                continue
    311306        raise ValidationError(self.error_messages['invalid'])
    312307
    313 DEFAULT_TIME_INPUT_FORMATS = (
    314     '%H:%M:%S',     # '14:30:59'
    315     '%H:%M',        # '14:30'
    316 )
    317 
    318308class TimeField(Field):
    319309    widget = TimeInput
    320310    default_error_messages = {
    class TimeField(Field):  
    323313
    324314    def __init__(self, input_formats=None, *args, **kwargs):
    325315        super(TimeField, self).__init__(*args, **kwargs)
    326         self.input_formats = input_formats or DEFAULT_TIME_INPUT_FORMATS
     316        self.input_formats = input_formats
    327317
    328318    def clean(self, value):
    329319        """
    class TimeField(Field):  
    335325            return None
    336326        if isinstance(value, datetime.time):
    337327            return value
    338         for format in self.input_formats:
     328        for format in self.input_formats or getformat('TIME_INPUT_FORMATS'):
    339329            try:
    340330                return datetime.time(*time.strptime(value, format)[3:6])
    341331            except ValueError:
    342332                continue
    343333        raise ValidationError(self.error_messages['invalid'])
    344334
    345 DEFAULT_DATETIME_INPUT_FORMATS = (
    346     '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
    347     '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
    348     '%Y-%m-%d',              # '2006-10-25'
    349     '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
    350     '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
    351     '%m/%d/%Y',              # '10/25/2006'
    352     '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
    353     '%m/%d/%y %H:%M',        # '10/25/06 14:30'
    354     '%m/%d/%y',              # '10/25/06'
    355 )
    356 
    357335class DateTimeField(Field):
    358336    widget = DateTimeInput
    359337    default_error_messages = {
    class DateTimeField(Field):  
    362340
    363341    def __init__(self, input_formats=None, *args, **kwargs):
    364342        super(DateTimeField, self).__init__(*args, **kwargs)
    365         self.input_formats = input_formats or DEFAULT_DATETIME_INPUT_FORMATS
     343        self.input_formats = input_formats
    366344
    367345    def clean(self, value):
    368346        """
    class DateTimeField(Field):  
    382360            if len(value) != 2:
    383361                raise ValidationError(self.error_messages['invalid'])
    384362            value = '%s %s' % tuple(value)
    385         for format in self.input_formats:
     363        for format in self.input_formats or getformat('DATETIME_INPUT_FORMATS'):
    386364            try:
    387365                return datetime.datetime(*time.strptime(value, format)[:6])
    388366            except ValueError:
  • django/forms/widgets.py

    diff --git a/django/forms/widgets.py b/django/forms/widgets.py
    index b1d2cb7..0161653 100644
    a b from django.utils.html import escape, conditional_escape  
    1515from django.utils.translation import ugettext
    1616from django.utils.encoding import StrAndUnicode, force_unicode
    1717from django.utils.safestring import mark_safe
     18from django.utils.formats import localize
    1819from django.utils import datetime_safe
    1920from datetime import time
    2021from util import flatatt
    class Input(Widget):  
    213214        final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
    214215        if value != '':
    215216            # Only add the 'value' attribute if a value is non-empty.
    216             final_attrs['value'] = force_unicode(value)
     217            final_attrs['value'] = force_unicode(localize(value, is_input=True))
    217218        return mark_safe(u'<input%s />' % flatatt(final_attrs))
    218219
    219220class TextInput(Input):
  • django/template/__init__.py

    diff --git a/django/template/__init__.py b/django/template/__init__.py
    index 8764bfa..4c386be 100644
    a b from django.utils.text import smart_split, unescape_string_literal  
    6060from django.utils.encoding import smart_unicode, force_unicode, smart_str
    6161from django.utils.translation import ugettext as _
    6262from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping
     63from django.utils.formats import localize
    6364from django.utils.html import escape
    6465
    6566__all__ = ('Template', 'Context', 'RequestContext', 'compile_string')
    def _render_value_in_context(value, context):  
    815816    means escaping, if required, and conversion to a unicode object. If value
    816817    is a string, it is expected to have already been translated.
    817818    """
     819    value = localize(value)
    818820    value = force_unicode(value)
    819821    if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData):
    820822        return escape(value)
  • django/template/debug.py

    diff --git a/django/template/debug.py b/django/template/debug.py
    index c58c854..382fb75 100644
    a b from django.template import Lexer, Parser, tag_re, NodeList, VariableNode, Templ  
    22from django.utils.encoding import force_unicode
    33from django.utils.html import escape
    44from django.utils.safestring import SafeData, EscapeData
     5from django.utils.formats import localize
    56
    67class DebugLexer(Lexer):
    78    def __init__(self, template_string, origin):
    class DebugNodeList(NodeList):  
    8485class DebugVariableNode(VariableNode):
    8586    def render(self, context):
    8687        try:
    87             output = force_unicode(self.filter_expression.resolve(context))
     88            output = self.filter_expression.resolve(context)
     89            output = localize(output)
     90            output = force_unicode(output)
    8891        except TemplateSyntaxError, e:
    8992            if not hasattr(e, 'source'):
    9093                e.source = self.source
  • django/template/defaultfilters.py

    diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
    index a8c2567..26b6b5e 100644
    a b from django.conf import settings  
    1818from django.utils.translation import ugettext, ungettext
    1919from django.utils.encoding import force_unicode, iri_to_uri
    2020from django.utils.safestring import mark_safe, SafeData
     21from django.utils.formats import date_format, number_format
    2122
    2223register = Library()
    2324
    def floatformat(text, arg=-1):  
    166167        return input_val
    167168
    168169    if not m and p < 0:
    169         return mark_safe(u'%d' % (int(d)))
     170        return mark_safe(number_format(u'%d' % (int(d)), 0))
    170171
    171172    if p == 0:
    172173        exp = Decimal(1)
    173174    else:
    174175        exp = Decimal('1.0') / (Decimal(10) ** abs(p))
    175176    try:
    176         return mark_safe(u'%s' % str(d.quantize(exp, ROUND_HALF_UP)))
     177        return mark_safe(number_format(u'%s' % str(d.quantize(exp, ROUND_HALF_UP)), abs(p)))
    177178    except InvalidOperation:
    178179        return input_val
    179180floatformat.is_safe = True
    def date(value, arg=None):  
    685686    if arg is None:
    686687        arg = settings.DATE_FORMAT
    687688    try:
    688         return format(value, arg)
     689        return date_format(value, arg)
    689690    except AttributeError:
    690         return ''
     691        try:
     692            return format(value, arg)
     693        except AttributeError:
     694            return ''
    691695date.is_safe = False
    692696
    693697def time(value, arg=None):
    def time(value, arg=None):  
    698702    if arg is None:
    699703        arg = settings.TIME_FORMAT
    700704    try:
    701         return time_format(value, arg)
     705        return date_format(value, arg)
    702706    except AttributeError:
    703         return ''
     707        try:
     708            return time_format(value, arg)
     709        except AttributeError:
     710            return ''
    704711time.is_safe = False
    705712
    706713def timesince(value, arg=None):
  • new file django/utils/formats.py

    diff --git a/django/utils/formats.py b/django/utils/formats.py
    new file mode 100644
    index 0000000..0976395
    - +  
     1import decimal
     2import datetime
     3
     4from django.conf import settings
     5from django.utils.translation import get_language
     6from django.utils.importlib import import_module
     7from django.utils import dateformat
     8from django.utils import numberformat
     9
     10def project_formats_module():
     11    """
     12    Returns the formats module for the current locale, defined
     13    on the project
     14    """
     15    if settings.FORMAT_MODULE_PATH:
     16        try:
     17            return import_module('.formats', '%s.%s' % (
     18                settings.FORMAT_MODULE_PATH, get_language().split('-')[0]))
     19        except ImportError:
     20            pass
     21    return None
     22
     23def django_formats_module():
     24    """
     25    Returns the formats module for the current locale, defined
     26    on Django
     27    """
     28    try:
     29        return import_module('.formats',
     30            'django.conf.locale.%s' % get_language().split('-')[0])
     31    except ImportError:
     32        return None
     33
     34def getformat(format_type):
     35    """
     36    For a specific format type, returns the format for the
     37    current language (locale) defaulting to the format on settings.
     38    format_type is the name of the format, for example 'DATE_FORMAT'
     39    """
     40    if settings.USE_I18N and settings.USE_FORMAT_I18N:
     41        for module in (project_formats_module(), django_formats_module()):
     42            if module:
     43                try:
     44                    return getattr(module, format_type)
     45                except AttributeError:
     46                    pass
     47    return getattr(settings, format_type)
     48
     49def date_format(value, format=None):
     50    """
     51    Formats a datetime.date or datetime.datetime object using a
     52    localizable format
     53    """
     54    return dateformat.format(value, getformat(format or 'DATE_FORMAT'))
     55
     56def number_format(value, decimal_pos=None):
     57    """
     58    Formats a numeric value using localization settings
     59    """
     60    return numberformat.format(
     61        value,
     62        getformat('DECIMAL_SEPARATOR'),
     63        decimal_pos,
     64        getformat('NUMBER_GROUPING'),
     65        getformat('THOUSAND_SEPARATOR'),
     66    )
     67
     68def localize(value, is_input=False):
     69    """
     70    Checks value, and if it has a localizable type (date,
     71    number...) it returns the value as a string using
     72    current locale format
     73    """
     74    if settings.USE_I18N and settings.USE_FORMAT_I18N:
     75        if isinstance(value, decimal.Decimal):
     76            return number_format(value)
     77        elif isinstance(value, float):
     78            return number_format(value)
     79        elif isinstance(value, int):
     80            return number_format(value)
     81        elif isinstance(value, datetime.datetime):
     82            if not is_input:
     83                return date_format(value, 'DATETIME_FORMAT')
     84            else:
     85                return value.strftime(getformat('DATETIME_INPUT_FORMATS')[0])
     86        elif isinstance(value, datetime.date):
     87            if not is_input:
     88                return date_format(value)
     89            else:
     90                return value.strftime(getformat('DATE_INPUT_FORMATS')[0])
     91        elif isinstance(value, datetime.time):
     92            if not is_input:
     93                return date_format(value, 'TIME_FORMAT')
     94            else:
     95                return value.strftime(getformat('TIME_INPUT_FORMATS')[0])
     96    return value
     97
  • new file django/utils/numberformat.py

    diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
    new file mode 100644
    index 0000000..78ecb2f
    - +  
     1from django.conf import settings
     2
     3def format(number, decimal_sep, decimal_pos, grouping=0, thousand_sep=''):
     4    """
     5    Gets a number (as a number or string), and returns it as a string,
     6    using formats definied as arguments:
     7
     8    * decimal_sep: Decimal separator symbol (for example ".")
     9    * decimal_pos: Number of decimal positions
     10    * grouping: Number of digits in every group limited by thousand separator
     11    * thousand_sep: Thousand separator symbol (for example ",")
     12
     13    """
     14    # sign
     15    if float(number) < 0:
     16        sign = '-'
     17    else:
     18        sign = ''
     19    # decimal part
     20    str_number = unicode(number)
     21    if str_number[0] == '-':
     22        str_number = str_number[1:]
     23    if '.' in str_number:
     24        int_part, dec_part = str_number.split('.')
     25        if decimal_pos:
     26            dec_part = dec_part[:decimal_pos]
     27    else:
     28        int_part, dec_part = str_number, ''
     29    if decimal_pos:
     30        dec_part = dec_part + ('0' * (decimal_pos - len(dec_part)))
     31    if dec_part: dec_part = decimal_sep + dec_part
     32    # grouping
     33    if settings.USE_THOUSAND_SEPARATOR and grouping:
     34        int_part_gd = ''
     35        for cnt, digit in enumerate(int_part[::-1]):
     36            if cnt and not cnt % grouping:
     37                int_part_gd += thousand_sep
     38            int_part_gd += digit
     39        int_part = int_part_gd[::-1]
     40
     41    return sign + int_part + dec_part
     42
  • django/utils/translation/trans_null.py

    diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
    index 98c6de6..7a57139 100644
    a b activate = lambda x: None  
    1818deactivate = deactivate_all = lambda: None
    1919get_language = lambda: settings.LANGUAGE_CODE
    2020get_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)
    2321check_for_language = lambda x: True
    2422
     23# date formats shouldn't be used using gettext anymore. This
     24# is kept for backward compatibility
    2525TECHNICAL_ID_MAP = {
    2626    "DATE_WITH_TIME_FULL": settings.DATETIME_FORMAT,
    2727    "DATE_FORMAT": settings.DATE_FORMAT,
    def to_locale(language):  
    5151
    5252def get_language_from_request(request):
    5353    return settings.LANGUAGE_CODE
     54
     55# get_date_formats and get_partial_date_formats aren't used anymore from django
     56# itself, and are kept for backward compatibility.
     57get_date_formats = lambda: (settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT)
     58get_partial_date_formats = lambda: (settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT)
  • django/utils/translation/trans_real.py

    diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
    index 48ed7cc..e9f0a36 100644
    a b def do_translate(message, translation_function):  
    266266    translation object to use. If no current translation is activated, the
    267267    message will be run through the default translation object.
    268268    """
     269    eol_message = message.replace('\r\n', '\n').replace('\r', '\n')
    269270    global _default, _active
    270271    t = _active.get(currentThread(), None)
    271272    if t is not None:
    272         result = getattr(t, translation_function)(message)
     273        result = getattr(t, translation_function)(eol_message)
    273274    else:
    274275        if _default is None:
    275276            from django.conf import settings
    276277            _default = translation(settings.LANGUAGE_CODE)
    277         result = getattr(_default, translation_function)(message)
     278        result = getattr(_default, translation_function)(eol_message)
    278279    if isinstance(message, SafeData):
    279280        return mark_safe(result)
    280281    return result
    def get_language_from_request(request):  
    389390
    390391    return settings.LANGUAGE_CODE
    391392
    392 def get_date_formats():
    393     """
    394     Checks whether translation files provide a translation for some technical
    395     message ID to store date and time formats. If it doesn't contain one, the
    396     formats provided in the settings will be used.
    397     """
    398     from django.conf import settings
    399     date_format = ugettext('DATE_FORMAT')
    400     datetime_format = ugettext('DATETIME_FORMAT')
    401     time_format = ugettext('TIME_FORMAT')
    402     if date_format == 'DATE_FORMAT':
    403         date_format = settings.DATE_FORMAT
    404     if datetime_format == 'DATETIME_FORMAT':
    405         datetime_format = settings.DATETIME_FORMAT
    406     if time_format == 'TIME_FORMAT':
    407         time_format = settings.TIME_FORMAT
    408     return date_format, datetime_format, time_format
    409 
    410 def get_partial_date_formats():
    411     """
    412     Checks whether translation files provide a translation for some technical
    413     message ID to store partial date formats. If it doesn't contain one, the
    414     formats provided in the settings will be used.
    415     """
    416     from django.conf import settings
    417     year_month_format = ugettext('YEAR_MONTH_FORMAT')
    418     month_day_format = ugettext('MONTH_DAY_FORMAT')
    419     if year_month_format == 'YEAR_MONTH_FORMAT':
    420         year_month_format = settings.YEAR_MONTH_FORMAT
    421     if month_day_format == 'MONTH_DAY_FORMAT':
    422         month_day_format = settings.MONTH_DAY_FORMAT
    423     return year_month_format, month_day_format
    424 
    425393dot_re = re.compile(r'\S')
    426394def blankout(src, char):
    427395    """
    def parse_accept_lang_header(lang_string):  
    537505        result.append((lang, priority))
    538506    result.sort(lambda x, y: -cmp(x[1], y[1]))
    539507    return result
     508
     509# get_date_formats and get_partial_date_formats aren't used anymore from django
     510# itself, and are kept for backward compatibility.
     511# Note that it's also important to keep format names maked for translation, so
     512# for compatibility we still want to have formats on translation catalogs. That
     513# makes template code like {{ my_date|date:_('DATE_FORMAT') }} go on working
     514def get_date_formats():
     515    """
     516    Checks whether translation files provide a translation for some technical
     517    message ID to store date and time formats. If it doesn't contain one, the
     518    formats provided in the settings will be used.
     519    """
     520    from django.conf import settings
     521    date_format = ugettext('DATE_FORMAT')
     522    datetime_format = ugettext('DATETIME_FORMAT')
     523    time_format = ugettext('TIME_FORMAT')
     524    if date_format == 'DATE_FORMAT':
     525        date_format = settings.DATE_FORMAT
     526    if datetime_format == 'DATETIME_FORMAT':
     527        datetime_format = settings.DATETIME_FORMAT
     528    if time_format == 'TIME_FORMAT':
     529        time_format = settings.TIME_FORMAT
     530    return date_format, datetime_format, time_format
     531
     532def get_partial_date_formats():
     533    """
     534    Checks whether translation files provide a translation for some technical
     535    message ID to store partial date formats. If it doesn't contain one, the
     536    formats provided in the settings will be used.
     537    """
     538    from django.conf import settings
     539    year_month_format = ugettext('YEAR_MONTH_FORMAT')
     540    month_day_format = ugettext('MONTH_DAY_FORMAT')
     541    if year_month_format == 'YEAR_MONTH_FORMAT':
     542        year_month_format = settings.YEAR_MONTH_FORMAT
     543    if month_day_format == 'MONTH_DAY_FORMAT':
     544        month_day_format = settings.MONTH_DAY_FORMAT
     545    return year_month_format, month_day_format
     546
  • django/views/i18n.py

    diff --git a/django/views/i18n.py b/django/views/i18n.py
    index 0280698..4bfbf5e 100644
    a b from django.conf import settings  
    33from django.utils import importlib
    44from django.utils.translation import check_for_language, activate, to_locale, get_language
    55from django.utils.text import javascript_quote
     6from django.utils.formats import project_formats_module, django_formats_module
    67import os
    78import gettext as gettext_module
    89
    def set_language(request):  
    3233                response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
    3334    return response
    3435
     36def get_formats():
     37    """
     38    Returns an iterator over all formats in formats file
     39    """
     40    FORMAT_SETTINGS = ('DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT',
     41        'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 'SHORT_DATE_FORMAT',
     42        'SHORT_DATETIME_FORMAT', 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR',
     43        'THOUSAND_SEPARATOR', 'NUMBER_GROUPING')
     44
     45    result = {}
     46    for module in (settings, django_formats_module(), project_formats_module()):
     47        if module:
     48            for attr in FORMAT_SETTINGS:
     49                try:
     50                    result[attr] = getattr(module, attr)
     51                except AttributeError:
     52                    pass
     53    return result
     54
    3555NullSource = """
    3656/* gettext identity library */
    3757
    def javascript_catalog(request, domain='djangojs', packages=None):  
    185205        else:
    186206            raise TypeError, k
    187207    csrc.sort()
    188     for k,v in pdict.items():
     208    for k, v in pdict.items():
    189209        src.append("catalog['%s'] = [%s];\n" % (javascript_quote(k), ','.join(["''"]*(v+1))))
     210    for k, v in get_formats().items():
     211        src.append("catalog['%s'] = '%s';\n" % (javascript_quote(k), javascript_quote(unicode(v))))
    190212    src.extend(csrc)
    191213    src.append(LibFoot)
    192214    src.append(InterPolate)
    193215    src = ''.join(src)
    194216    return http.HttpResponse(src, 'text/javascript')
     217
  • docs/ref/settings.txt

    diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
    index 8ff1509..1b57adf 100644
    a b DATE_FORMAT  
    288288
    289289Default: ``'N j, Y'`` (e.g. ``Feb. 4, 2003``)
    290290
    291 The default formatting to use for date fields on Django admin change-list
    292 pages -- and, possibly, by other parts of the system. See
    293 :ttag:`allowed date format strings <now>`.
     291The default formatting to use for date fields in any part of the system.
     292Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will
     293be applied. See :ttag:`allowed date format strings <now>`.
     294
     295See also ``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``SHORT_DATE_FORMAT``.
     296
     297.. setting:: DATE_INPUT_FORMATS
    294298
    295 See also ``DATETIME_FORMAT``, ``TIME_FORMAT``, ``YEAR_MONTH_FORMAT``
    296 and ``MONTH_DAY_FORMAT``.
     299DATE_INPUT_FORMATS
     300------------------
     301
     302Default::
     303
     304    ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y',
     305    '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y',
     306    '%B %d, %Y', '%d %B %Y', '%d %B, %Y')
     307
     308A tuple of formats that will be accepted when inputting data on a date
     309field. Formats will be tried in order, using the first valid.
     310Note that these format strings are specified in Python's datetime_ module
     311syntax, that is different from the one used by Django for formatting dates
     312to be displayed.
     313
     314See also ``DATETIME_INPUT_FORMATS`` and ``TIME_INPUT_FORMATS``.
     315
     316.. _datetime: http://docs.python.org/library/datetime.html#strftime-behavior
    297317
    298318.. setting:: DATETIME_FORMAT
    299319
    DATETIME_FORMAT  
    302322
    303323Default: ``'N j, Y, P'`` (e.g. ``Feb. 4, 2003, 4 p.m.``)
    304324
    305 The default formatting to use for datetime fields on Django admin change-list
    306 pages -- and, possibly, by other parts of the system. See
    307 :ttag:`allowed date format strings <now>`.
     325The default formatting to use for datetime fields in any part of the system.
     326Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will
     327be applied. See :ttag:`allowed date format strings <now>`.
     328
     329See also ``DATE_FORMAT``, ``TIME_FORMAT`` and ``SHORT_DATETIME_FORMAT``.
    308330
    309 See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``,
    310 ``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``.
     331.. setting:: DATETIME_INPUT_FORMATS
     332
     333DATETIME_INPUT_FORMATS
     334----------------------
     335
     336Default::
     337
     338    ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', '%Y-%m-%d',
     339    '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M', '%m/%d/%Y',
     340    '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M', '%m/%d/%y')
     341
     342A tuple of formats that will be accepted when inputting data on a datetime
     343field. Formats will be tried in order, using the first valid.
     344Note that these format strings are specified in Python's datetime_ module
     345syntax, that is different from the one used by Django for formatting dates
     346to be displayed.
     347
     348See also ``DATE_INPUT_FORMATS`` and ``TIME_INPUT_FORMATS``.
     349
     350.. _datetime: http://docs.python.org/library/datetime.html#strftime-behavior
    311351
    312352.. setting:: DEBUG
    313353
    will be suppressed, and exceptions will propagate upwards. This can  
    347387be useful for some test setups, and should never be used on a live
    348388site.
    349389
     390.. setting:: DECIMAL_SEPARATOR
     391
     392DECIMAL_SEPARATOR
     393-----------------
     394
     395Default: ``'.'`` (Dot)
     396
     397Default decimal separator used when formatting decimal numbers.
    350398
    351399.. setting:: DEFAULT_CHARSET
    352400
    system's standard umask.  
    596644
    597645.. _documentation for os.chmod: http://docs.python.org/lib/os-file-dir.html
    598646
     647.. setting:: FIRST_DAY_OF_WEEK
     648
     649FIRST_DAY_OF_WEEK
     650-----------------
     651
     652Default: ``0`` (Sunday)
     653
     654Number representing the first day of the week. This is specially useful
     655when displaying a calendar. This value is only used when not using
     656format internationalization, or when a format cannot be found for the
     657current locale.
     658
     659The value must be an integer from 0 to 6, where 0 means Sunday, 1 means
     660Monday and so on.
     661
    599662.. setting:: FIXTURE_DIRS
    600663
    601664FIXTURE_DIRS
    environment variable in any HTTP request. This setting can be used to override  
    617680the server-provided value of ``SCRIPT_NAME``, which may be a rewritten version
    618681of the preferred value or not supplied at all.
    619682
     683.. setting:: FORMAT_MODULE_PATH
     684
     685FORMAT_MODULE_PATH
     686------------------
     687
     688Default: ``None``
     689
     690A full Python path to a Python package that contains format definitions for
     691project locales. If not ``None``, Django will check for a ``formats.py``
     692file, under the directory named as the current locale, and will use the
     693formats defined on this file.
     694
     695For example, if ``FORMAT_MODULE_PATH`` is set to ``mysite.formats``, and
     696current language is ``en`` (English), Django will expect a directory tree
     697like::
     698
     699    mysite/
     700        formats/
     701            __init__.py
     702            en/
     703                __init__.py
     704                formats.py
     705
     706Available formats are ``DATE_FORMAT``, ``TIME_FORMAT``, ``DATETIME_FORMAT``,
     707``YEAR_MONTH_FORMAT``, ``MONTH_DAY_FORMAT``, ``SHORT_DATE_FORMAT``,
     708``SHORT_DATETIME_FORMAT``, ``FIRST_DAY_OF_WEEK``, ``DECIMAL_SEPARATOR``,
     709``THOUSAND_SEPARATOR`` and ``NUMBER_GROUPING``.
     710
    620711.. setting:: IGNORABLE_404_ENDS
    621712
    622713IGNORABLE_404_ENDS
    locales have different formats. For example, U.S. English would say  
    886977See :ttag:`allowed date format strings <now>`. See also ``DATE_FORMAT``,
    887978``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``YEAR_MONTH_FORMAT``.
    888979
     980.. setting:: NUMBER_GROUPING
     981
     982NUMBER_GROUPING
     983----------------
     984
     985Default: ``0``
     986
     987Number of digits grouped together on the integer part of a number. Common use
     988is to display a thousand separator. If this setting is ``0``, then, no grouping
     989will be applied to the number. If this setting is greater than ``0`` then the
     990setting ``THOUSAND_SEPARATOR`` will be used as the separator between those
     991groups.
     992
     993See also ``THOUSAND_SEPARATOR``
     994
    889995.. setting:: PREPEND_WWW
    890996
    891997PREPEND_WWW
    Default: ``False``  
    10771183Whether to save the session data on every request. See
    10781184:ref:`topics-http-sessions`.
    10791185
     1186.. setting:: SHORT_DATE_FORMAT
     1187
     1188SHORT_DATE_FORMAT
     1189-----------------
     1190
     1191Default: ``m/d/Y`` (e.g. ``12/31/2003``)
     1192
     1193An available formatting that can be used for date fields on templates.
     1194Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will
     1195be applied. See :ttag:`allowed date format strings <now>`.
     1196
     1197See also ``DATE_FORMAT`` and ``SHORT_DATETIME_FORMAT``.
     1198
     1199.. setting:: SHORT_DATETIME_FORMAT
     1200
     1201SHORT_DATETIME_FORMAT
     1202---------------------
     1203
     1204Default: ``m/d/Y P`` (e.g. ``12/31/2003 4 p.m.``)
     1205
     1206An available formatting that can be used for datetime fields on templates.
     1207Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will
     1208be applied. See :ttag:`allowed date format strings <now>`.
     1209
     1210See also ``DATE_FORMAT`` and ``SHORT_DATETIME_FORMAT``.
     1211
    10801212.. setting:: SITE_ID
    10811213
    10821214SITE_ID
    The name of the method to use for starting the test suite. See  
    12311363
    12321364.. _Testing Django Applications: ../testing/
    12331365
     1366.. setting:: THOUSAND_SEPARATOR
     1367
     1368THOUSAND_SEPARATOR
     1369------------------
     1370
     1371Default ``,`` (Comma)
     1372
     1373Default thousand separator used when formatting numbers. This setting is
     1374used only when ``NUMBER_GROUPPING`` is set.
     1375
     1376See also ``NUMBER_GROUPPING``, ``DECIMAL_SEPARATOR``
     1377
    12341378.. setting:: TIME_FORMAT
    12351379
    12361380TIME_FORMAT
    TIME_FORMAT  
    12381382
    12391383Default: ``'P'`` (e.g. ``4 p.m.``)
    12401384
    1241 The default formatting to use for time fields on Django admin change-list
    1242 pages -- and, possibly, by other parts of the system. See
    1243 :ttag:`allowed date format strings <now>`.
     1385The default formatting to use for time fields in any part of the system.
     1386Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will
     1387be applied. See :ttag:`allowed date format strings <now>`.
    12441388
    1245 See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``,
    1246 ``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``.
     1389See also ``DATE_FORMAT`` and ``DATETIME_FORMAT``.
     1390
     1391.. setting:: TIME_INPUT_FORMATS
     1392
     1393TIME_INPUT_FORMATS
     1394------------------
     1395
     1396Default: ``('%H:%M:%S', '%H:%M')``
     1397
     1398A tuple of formats that will be accepted when inputting data on a time
     1399field. Formats will be tried in order, using the first valid.
     1400Note that these format strings are specified in Python's datetime_ module
     1401syntax, that is different from the one used by Django for formatting dates
     1402to be displayed.
     1403
     1404See also ``DATE_INPUT_FORMATS`` and ``DATETIME_INPUT_FORMATS``.
     1405
     1406.. _datetime: http://docs.python.org/library/datetime.html#strftime-behavior
    12471407
    12481408.. setting:: TIME_ZONE
    12491409
    A boolean that specifies whether to output the "Etag" header. This saves  
    12981458bandwidth but slows down performance. This is only used if ``CommonMiddleware``
    12991459is installed (see :ref:`topics-http-middleware`).
    13001460
     1461.. setting:: USE_FORMAT_I18N
     1462
     1463USE_FORMAT_I18N
     1464---------------
     1465
     1466Default ``False``
     1467
     1468A boolean that specifies if data will be localized by default or not. If this is
     1469set to ``True``, Django will display numbers and dates using the format of the
     1470current locale. It is required to set ``USE_I18N`` to ``True`` to allow data
     1471format localization.
     1472
     1473See also ``USE_I18N``
     1474
    13011475.. setting:: USE_I18N
    13021476
    13031477USE_I18N
    enabled. This provides an easy way to turn it off, for performance. If this is  
    13101484set to ``False``, Django will make some optimizations so as not to load the
    13111485internationalization machinery.
    13121486
     1487See also ``USE_FORMAT_I18N``
     1488
     1489.. setting:: USE_THOUSAND_SEPARATOR
     1490
     1491USE_THOUSAND_SEPARATOR
     1492----------------------
     1493
     1494Default ``False``
     1495
     1496A boolean that specifies wheter to display numbers using a thousand separator.
     1497If this is set to ``True``, Django will use values from ``THOUSAND_SEPARATOR``
     1498and ``NUMBER_GROUPING`` from current locale, to format the number.
     1499``USE_FORMAT_I18N`` must be set to ``True``, in order to format numbers.
     1500
     1501See also ``THOUSAND_SEPARATOR`` and ``NUMBER_GROUPING``.
     1502
    13131503.. setting:: YEAR_MONTH_FORMAT
    13141504
    13151505YEAR_MONTH_FORMAT
  • docs/ref/templates/builtins.txt

    diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
    index bf2d9e8..29ccfef 100644
    a b If ``value`` is ``"String with spaces"``, the output will be ``"Stringwithspaces  
    10471047date
    10481048~~~~
    10491049
    1050 Formats a date according to the given format (same as the `now`_ tag).
     1050Formats a date according to the given format.
     1051
     1052Given format can be one of the predefined ones ``DATE_FORMAT``, ``DATETIME_FORMAT``,
     1053``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``, or a custom format, same as the
     1054`now`_ tag. Note that prefedined formats vary depending on the current locale.
    10511055
    10521056For example::
    10531057
    When used without a format string::  
    10621066    {{ value|date }}
    10631067
    10641068...the formatting string defined in the :setting:`DATE_FORMAT` setting will be
    1065 used.
     1069used, without applying any localization.
    10661070
    10671071.. templatefilter:: default
    10681072
    output will be ``"Joel is a slug"``.  
    16101614time
    16111615~~~~
    16121616
    1613 Formats a time according to the given format (same as the `now`_ tag).
     1617Formats a time according to the given format.
     1618
     1619Given format can be the predefined one ``TIME_FORMAT``, or a custom format,
     1620same as the `now`_ tag. Note that the predefined format is locale depending.
     1621
    16141622The time filter will only accept parameters in the format string that relate
    16151623to the time of day, not the date (for obvious reasons). If you need to
    16161624format a date, use the `date`_ filter.
    When used without a format string::  
    16271635    {{ value|time }}
    16281636
    16291637...the formatting string defined in the :setting:`TIME_FORMAT` setting will be
    1630 used.
     1638used, without aplying any localization.
    16311639
    16321640.. templatefilter:: timesince
    16331641
  • docs/topics/i18n.txt

    diff --git a/docs/topics/i18n.txt b/docs/topics/i18n.txt
    index c5f4ab6..0fd2663 100644
    a b  
    44Internationalization
    55====================
    66
    7 Django has full support for internationalization of text in code and templates.
    8 Here's how it works.
     7Django has full support for internationalization, including translation
     8capabilities of text in code and templates, and format localization for
     9dates and numbers. Here's how it works.
    910
    1011Overview
    1112========
    1213
    1314The goal of internationalization is to allow a single Web application to offer
    14 its content and functionality in multiple languages.
     15its content and functionality in multiple languages and locales.
    1516
    16 You, the Django developer, can accomplish this goal by adding a minimal amount
    17 of hooks to your Python code and templates. These hooks are called
    18 **translation strings**. They tell Django: "This text should be translated into
    19 the end user's language, if a translation for this text is available in that
    20 language."
     17For text translation, you, the Django developer, can accomplish this goal by
     18adding a minimal amount of hooks to your Python code and templates. These hooks
     19are called **translation strings**. They tell Django: "This text should be
     20translated into the end user's language, if a translation for this text is
     21available in that language."
    2122
    2223Django takes care of using these hooks to translate Web apps, on the fly,
    2324according to users' language preferences.
    Essentially, Django does two things:  
    2930    * It uses these hooks to translate Web apps for particular users according
    3031      to their language preferences.
    3132
     33For format localization, it's just necessary to set
     34:setting:`USE_FORMAT_I18N = True <USE_FORMAT_I18N>` in your settings file. If
     35:settings:`USE_FORMAT_I18N` is set to ``True``, then Django will display
     36numbers and dates in the format of the current locale. That includes field
     37representation on templates, and allowed input formats on the admin.
     38
    3239If you don't need internationalization in your app
    3340==================================================
    3441
    have been found to not support this command. Do not attempt to use Django  
    10741081translation utilities with a ``gettext`` package if the command ``xgettext
    10751082--version`` entered at a Windows command prompt causes a popup window saying
    10761083"xgettext.exe has generated errors and will be closed by Windows".
     1084
     1085Format localization
     1086===================
     1087
     1088Django's formatting system is disabled by default. To enable it, it's necessay
     1089to set :setting:`USE_FORMAT_I18N = True <USE_FORMAT_I18N>` in your settings
     1090file.  Note that :setting:`USE_FORMAT_I18N` requires `USE_I18N` to be ``True``.
     1091
     1092When using Django's formatting system, dates and numbers on templates will be
     1093displayed using the format specified for the current locale. That means, two
     1094users accessing the same content, but in different language, will see date and
     1095number fields formatted in different ways, depending on the format for their
     1096current locale.
     1097
     1098Django will also use localized formats when parsing data in forms. That means
     1099Django uses different formats for different locales when guessing the format
     1100used by the user when inputting data on forms. Note that Django uses different
     1101formats for displaying data, and for parsing it.
     1102
     1103Creating custom format files
     1104----------------------------
     1105
     1106Django provides format definitions for many locales, but sometimes you could
     1107want to create your own ones, because a format files doesn't exist for your
     1108locale, or because you want to overwrite some of the values.
     1109
     1110To use custom formats, first thing to do, is to specify the path where you'll
     1111place format files. To do that, just set :setting:`FORMAT_MODULE_PATH` setting
     1112to the the path (in the format ``'foo.bar.baz``) where format files will
     1113exists.
     1114
     1115Files are not placed directly in this directory, but in a directory named as
     1116the locale. File must be named ``formats.py``.
     1117
     1118For customazing English formats, a structure like this would be needed::
     1119
     1120    mysite/
     1121        formats/
     1122            __init__.py
     1123            en/
     1124                __init__.py
     1125                formats.py
     1126
     1127where :file:`formats.py` contains custom format definitions. For example::
     1128
     1129    THOUSAND_SEPARATOR = ' '
     1130
     1131to use a space as thousand separator, instead of the default for English,
     1132comma.
     1133
  • deleted file tests/regressiontests/i18n/misc.py

    diff --git a/tests/regressiontests/i18n/misc.py b/tests/regressiontests/i18n/misc.py
    deleted file mode 100644
    index f8f35ad..0000000
    + -  
    1 import sys
    2 
    3 tests = """
    4 >>> from django.utils.translation.trans_real import parse_accept_lang_header
    5 >>> p = parse_accept_lang_header
    6 
    7 #
    8 # Testing HTTP header parsing. First, we test that we can parse the values
    9 # according to the spec (and that we extract all the pieces in the right order).
    10 #
    11 
    12 Good headers.
    13 >>> p('de')
    14 [('de', 1.0)]
    15 >>> p('en-AU')
    16 [('en-AU', 1.0)]
    17 >>> p('*;q=1.00')
    18 [('*', 1.0)]
    19 >>> p('en-AU;q=0.123')
    20 [('en-AU', 0.123)]
    21 >>> p('en-au;q=0.1')
    22 [('en-au', 0.10000000000000001)]
    23 >>> p('en-au;q=1.0')
    24 [('en-au', 1.0)]
    25 >>> p('da, en-gb;q=0.25, en;q=0.5')
    26 [('da', 1.0), ('en', 0.5), ('en-gb', 0.25)]
    27 >>> p('en-au-xx')
    28 [('en-au-xx', 1.0)]
    29 >>> p('de,en-au;q=0.75,en-us;q=0.5,en;q=0.25,es;q=0.125,fa;q=0.125')
    30 [('de', 1.0), ('en-au', 0.75), ('en-us', 0.5), ('en', 0.25), ('es', 0.125), ('fa', 0.125)]
    31 >>> p('*')
    32 [('*', 1.0)]
    33 >>> p('de;q=0.')
    34 [('de', 1.0)]
    35 >>> p('')
    36 []
    37 
    38 Bad headers; should always return [].
    39 >>> p('en-gb;q=1.0000')
    40 []
    41 >>> p('en;q=0.1234')
    42 []
    43 >>> p('en;q=.2')
    44 []
    45 >>> p('abcdefghi-au')
    46 []
    47 >>> p('**')
    48 []
    49 >>> p('en,,gb')
    50 []
    51 >>> p('en-au;q=0.1.0')
    52 []
    53 >>> p('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZ,en')
    54 []
    55 >>> p('da, en-gb;q=0.8, en;q=0.7,#')
    56 []
    57 >>> p('de;q=2.0')
    58 []
    59 >>> p('de;q=0.a')
    60 []
    61 >>> p('')
    62 []
    63 
    64 #
    65 # Now test that we parse a literal HTTP header correctly.
    66 #
    67 
    68 >>> from django.utils.translation.trans_real import get_language_from_request
    69 >>> g = get_language_from_request
    70 >>> from django.http import HttpRequest
    71 >>> r = HttpRequest
    72 >>> r.COOKIES = {}
    73 
    74 These tests assumes the es, es_AR, pt and pt_BR translations exit in the Django
    75 source tree.
    76 >>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt-br'}
    77 >>> g(r)
    78 'pt-br'
    79 >>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt'}
    80 >>> g(r)
    81 'pt'
    82 >>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'es,de'}
    83 >>> g(r)
    84 'es'
    85 >>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-ar,de'}
    86 >>> g(r)
    87 'es-ar'
    88 """
    89 
    90 # Python 2.3 and 2.4 return slightly different results for completely bogus
    91 # locales, so we omit this test for that anything below 2.4. It's relatively
    92 # harmless in any cases (GIGO). This also means this won't be executed on
    93 # Jython currently, but life's like that sometimes. (On those platforms,
    94 # passing in a truly bogus locale will get you the default locale back.)
    95 if sys.version_info >= (2, 5):
    96     tests += """
    97 This test assumes there won't be a Django translation to a US variation
    98 of the Spanish language, a safe assumption. When the user sets it
    99 as the preferred language, the main 'es' translation should be selected
    100 instead.
    101 >>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-us'}
    102 >>> g(r)
    103 'es'
    104 """
    105 
    106 tests += """
    107 This tests the following scenario: there isn't a main language (zh)
    108 translation of Django but there is a translation to variation (zh_CN)
    109 the user sets zh-cn as the preferred language, it should be selected by
    110 Django without falling back nor ignoring it.
    111 >>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,de'}
    112 >>> g(r)
    113 'zh-cn'
    114 """
  • tests/regressiontests/i18n/tests.py

    diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
    index 94e792c..2c1acac 100644
    a b  
    1 # coding: utf-8
    2 import misc
    3 
    4 regressions = ur"""
    5 Format string interpolation should work with *_lazy objects.
    6 
    7 >>> from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy
    8 >>> s = ugettext_lazy('Add %(name)s')
    9 >>> d = {'name': 'Ringo'}
    10 >>> s % d
    11 u'Add Ringo'
    12 >>> activate('de')
    13 >>> s % d
    14 u'Ringo hinzuf\xfcgen'
    15 >>> activate('pl')
    16 >>> s % d
    17 u'Dodaj Ringo'
    18 >>> deactivate()
    19 
    20 It should be possible to compare *_lazy objects.
    21 
    22 >>> s1 = ugettext_lazy('Add %(name)s')
    23 >>> s == s1
    24 True
    25 >>> s2 = gettext_lazy('Add %(name)s')
    26 >>> s3 = gettext_lazy('Add %(name)s')
    27 >>> s2 == s3
    28 True
    29 >>> s == s2
    30 True
    31 >>> s4 = ugettext_lazy('Some other string')
    32 >>> s == s4
    33 False
    34 
    35 unicode(string_concat(...)) should not raise a TypeError - #4796
    36 
    37 >>> import django.utils.translation
    38 >>> reload(django.utils.translation)
    39 <module 'django.utils.translation' from ...>
    40 >>> unicode(django.utils.translation.string_concat("dja", "ngo"))
    41 u'django'
    42 
    43 Translating a string requiring no auto-escaping shouldn't change the "safe"
    44 status.
    45 
    46 >>> from django.utils.safestring import mark_safe, SafeString
    47 >>> s = mark_safe('Password')
    48 >>> type(s)
    49 <class 'django.utils.safestring.SafeString'>
    50 >>> activate('de')
    51 >>> type(ugettext(s))
    52 <class 'django.utils.safestring.SafeUnicode'>
    53 >>> deactivate()
    54 
    55 >>> SafeString('a') + s
    56 'aPassword'
    57 >>> s + SafeString('a')
    58 'Passworda'
    59 >>> s + mark_safe('a')
    60 'Passworda'
    61 >>> mark_safe('a') + s
    62 'aPassword'
    63 >>> mark_safe('a') + mark_safe('s')
    64 'as'
    65 >>> print s
    66 Password
    67 """
    68 
    69 __test__ = {
    70     'regressions': regressions,
    71     'misc': misc.tests,
    72 }
     1import sys
     2from django.test import TestCase, client
     3from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy
     4
     5class TranslationTests(TestCase):
     6
     7    def test_lazy_objects(self):
     8        """
     9        Format string interpolation should work with *_lazy objects.
     10        """
     11        s = ugettext_lazy('Add %(name)s')
     12        d = {'name': 'Ringo'}
     13        self.assertEqual(u'Add Ringo', s % d)
     14        activate('de')
     15        self.assertEqual(u'Ringo hinzuf\xfcgen', s % d)
     16        activate('pl')
     17        self.assertEqual(u'Dodaj Ringo', s % d)
     18        deactivate()
     19
     20        # It should be possible to compare *_lazy objects.
     21        s1 = ugettext_lazy('Add %(name)s')
     22        self.assertEqual(True, s == s1)
     23        s2 = gettext_lazy('Add %(name)s')
     24        s3 = gettext_lazy('Add %(name)s')
     25        self.assertEqual(True, s2 == s3)
     26        self.assertEqual(True, s == s2)
     27        s4 = ugettext_lazy('Some other string')
     28        self.assertEqual(False, s == s4)
     29
     30    def test_string_concat(self):
     31        """
     32        unicode(string_concat(...)) should not raise a TypeError - #4796
     33        """
     34        import django.utils.translation
     35        self.assertEqual(django.utils.translation, reload(django.utils.translation))
     36        self.assertEqual(u'django', unicode(django.utils.translation.string_concat("dja", "ngo")))
     37
     38    def test_safe_status(self):
     39        """
     40        Translating a string requiring no auto-escaping shouldn't change the "safe" status.
     41        """
     42        from django.utils.safestring import mark_safe, SafeString, SafeUnicode
     43        s = mark_safe('Password')
     44        self.assertEqual(SafeString, type(s))
     45        activate('de')
     46        self.assertEqual(SafeUnicode, type(ugettext(s)))
     47        deactivate()
     48        self.assertEqual('aPassword', SafeString('a') + s)
     49        self.assertEqual('Passworda', s + SafeString('a'))
     50        self.assertEqual('Passworda', s + mark_safe('a'))
     51        self.assertEqual('aPassword', mark_safe('a') + s)
     52        self.assertEqual('as', mark_safe('a') + mark_safe('s'))
     53        #self.assertEqual(Password, print s)
     54
     55    def test_maclines(self):
     56        """
     57        Translations on files with mac or dos end of lines will be converted
     58        to unix eof in .po catalogs, and they have to match when retrieved
     59        """
     60        from django.utils.translation.trans_real import translation
     61        ca_translation = translation('ca')
     62        ca_translation._catalog[u'Mac\nEOF\n'] = u'Catalan Mac\nEOF\n'
     63        ca_translation._catalog[u'Win\nEOF\n'] = u'Catalan Win\nEOF\n'
     64        activate('ca')
     65        self.assertEqual(u'Catalan Mac\nEOF\n', ugettext(u'Mac\rEOF\r'))
     66        self.assertEqual(u'Catalan Win\nEOF\n', ugettext(u'Win\r\nEOF\r\n'))
     67        deactivate()
     68
     69    def test_dates_and_numbers(self):
     70        """
     71        Localization of dates and numbers
     72        """
     73        import datetime
     74        import decimal
     75        from django.conf import settings
     76        from django.utils.formats import getformat, date_format, number_format, localize
     77        from django.utils.numberformat import format
     78        from django import template, forms
     79        from django.forms.extras import SelectDateWidget
     80
     81        old_use_i18n = settings.USE_I18N
     82        old_use_format_i18n = settings.USE_FORMAT_I18N
     83        old_use_thousand_separator = settings.USE_THOUSAND_SEPARATOR
     84
     85        n = decimal.Decimal('66666.666')
     86        f = 99999.999
     87        d = datetime.date(2009, 12, 31)
     88        dt = datetime.datetime(2009, 12, 31, 20, 50)
     89        ctxt = template.Context({'n': n, 'd': d, 'dt': dt, 'f': f})
     90
     91        # Locale independent
     92
     93        class I18nForm(forms.Form):
     94            decimal_field = forms.DecimalField()
     95            float_field = forms.FloatField()
     96            date_field = forms.DateField()
     97            datetime_field = forms.DateTimeField()
     98            time_field = forms.TimeField()
     99
     100        class SelectDateForm(forms.Form):
     101            date_field = forms.DateField(widget=SelectDateWidget)
     102
     103        settings.USE_FORMAT_I18N = True
     104        settings.USE_THOUSAND_SEPARATOR = False
     105        self.assertEqual(u'66666.66', format(n, decimal_sep='.', decimal_pos=2, grouping=3, thousand_sep=','))
     106        self.assertEqual(u'66666A6', format(n, decimal_sep='A', decimal_pos=1, grouping=1, thousand_sep='B'))
     107
     108        settings.USE_THOUSAND_SEPARATOR = True
     109        self.assertEqual(u'66,666.66', format(n, decimal_sep='.', decimal_pos=2, grouping=3, thousand_sep=','))
     110        self.assertEqual(u'6B6B6B6B6A6', format(n, decimal_sep='A', decimal_pos=1, grouping=1, thousand_sep='B'))
     111        self.assertEqual(u'-66666.6', format(-66666.666, decimal_sep='.', decimal_pos=1))
     112        self.assertEqual(u'-66666.0', format(int('-66666'), decimal_sep='.', decimal_pos=1))
     113
     114        # Catalan locale with format i18n disabled translations will be used, but not formats
     115
     116        settings.USE_FORMAT_I18N = False
     117        activate('ca')
     118        self.assertEqual('N j, Y', getformat('DATE_FORMAT'))
     119        self.assertEqual(0, getformat('FIRST_DAY_OF_WEEK'))
     120        self.assertEqual('.', getformat('DECIMAL_SEPARATOR'))
     121        self.assertEqual(u'des. 31, 2009', date_format(d))
     122        self.assertEqual(u'desembre 2009', date_format(d, 'YEAR_MONTH_FORMAT'))
     123        self.assertEqual(u'12/31/2009 8:50 p.m.', date_format(dt, 'SHORT_DATETIME_FORMAT'))
     124        self.assertEqual('No localizable', localize('No localizable'))
     125        self.assertEqual(decimal.Decimal('66666.666'), localize(n))
     126        self.assertEqual(99999.999, localize(f))
     127        self.assertEqual(datetime.date(2009, 12, 31), localize(d))
     128        self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), localize(dt))
     129        self.assertEqual(u'66666.666', template.Template('{{ n }}').render(ctxt))
     130        self.assertEqual(u'99999.999', template.Template('{{ f }}').render(ctxt))
     131        self.assertEqual(u'2009-12-31', template.Template('{{ d }}').render(ctxt))
     132        self.assertEqual(u'2009-12-31 20:50:00', template.Template('{{ dt }}').render(ctxt))
     133        self.assertEqual(u'66666.67', template.Template('{{ n|floatformat:2 }}').render(ctxt))
     134        self.assertEqual(u'100000.0', template.Template('{{ f|floatformat }}').render(ctxt))
     135        self.assertEqual(u'12/31/2009', template.Template('{{ d|date:"SHORT_DATE_FORMAT" }}').render(ctxt))
     136        self.assertEqual(u'12/31/2009 8:50 p.m.', template.Template('{{ dt|date:"SHORT_DATETIME_FORMAT" }}').render(ctxt))
     137
     138        form = I18nForm({
     139            'decimal_field': u'66666,666',
     140            'float_field': u'99999,999',
     141            'date_field': u'31/12/2009',
     142            'datetime_field': u'31/12/2009 20:50',
     143            'time_field': u'20:50'
     144        })
     145        self.assertEqual(False, form.is_valid())
     146        self.assertEqual([u'Introdu\xefu un n\xfamero.'], form.errors['float_field'])
     147        self.assertEqual([u'Introdu\xefu un n\xfamero.'], form.errors['decimal_field'])
     148        self.assertEqual([u'Introdu\xefu una data v\xe0lida.'], form.errors['date_field'])
     149        self.assertEqual([u'Introdu\xefu una data/hora v\xe0lides.'], form.errors['datetime_field'])
     150
     151        form2 = SelectDateForm({
     152            'date_field_month': u'12',
     153            'date_field_day': u'31',
     154            'date_field_year': u'2009'
     155        })
     156        self.assertEqual(True, form2.is_valid())
     157        self.assertEqual(datetime.date(2009, 12, 31), form2.cleaned_data['date_field'])
     158        self.assertEqual(u'<select name="mydate_month" id="id_mydate_month">\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>', SelectDateWidget().render('mydate', datetime.date(2009, 12, 31)))
     159        deactivate()
     160
     161        # Catalan locale
     162
     163        settings.USE_FORMAT_I18N = True
     164        activate('ca')
     165        self.assertEqual('j \de F \de Y', getformat('DATE_FORMAT'))
     166        self.assertEqual(1, getformat('FIRST_DAY_OF_WEEK'))
     167        self.assertEqual(',', getformat('DECIMAL_SEPARATOR'))
     168        self.assertEqual(u'31 de desembre de 2009', date_format(d))
     169        self.assertEqual(u'desembre del 2009', date_format(d, 'YEAR_MONTH_FORMAT'))
     170        self.assertEqual(u'31/12/2009 20:50', date_format(dt, 'SHORT_DATETIME_FORMAT'))
     171        self.assertEqual('No localizable', localize('No localizable'))
     172
     173        settings.USE_THOUSAND_SEPARATOR = True
     174        self.assertEqual(u'66.666,666', localize(n))
     175        self.assertEqual(u'99.999,999', localize(f))
     176
     177        settings.USE_THOUSAND_SEPARATOR = False
     178        self.assertEqual(u'66666,666', localize(n))
     179        self.assertEqual(u'99999,999', localize(f))
     180        self.assertEqual(u'31 de desembre de 2009', localize(d))
     181        self.assertEqual(u'31 de desembre de 2009 a les 20:50', localize(dt))
     182
     183        settings.USE_THOUSAND_SEPARATOR = True
     184        self.assertEqual(u'66.666,666', template.Template('{{ n }}').render(ctxt))
     185        self.assertEqual(u'99.999,999', template.Template('{{ f }}').render(ctxt))
     186
     187        settings.USE_THOUSAND_SEPARATOR = False
     188        self.assertEqual(u'66666,666', template.Template('{{ n }}').render(ctxt))
     189        self.assertEqual(u'99999,999', template.Template('{{ f }}').render(ctxt))
     190        self.assertEqual(u'31 de desembre de 2009', template.Template('{{ d }}').render(ctxt))
     191        self.assertEqual(u'31 de desembre de 2009 a les 20:50', template.Template('{{ dt }}').render(ctxt))
     192        self.assertEqual(u'66666,67', template.Template('{{ n|floatformat:2 }}').render(ctxt))
     193        self.assertEqual(u'100000,0', template.Template('{{ f|floatformat }}').render(ctxt))
     194        self.assertEqual(u'31/12/2009', template.Template('{{ d|date:"SHORT_DATE_FORMAT" }}').render(ctxt))
     195        self.assertEqual(u'31/12/2009 20:50', template.Template('{{ dt|date:"SHORT_DATETIME_FORMAT" }}').render(ctxt))
     196
     197        form3 = I18nForm({
     198            'decimal_field': u'66666,666',
     199            'float_field': u'99999,999',
     200            'date_field': u'31/12/2009',
     201            'datetime_field': u'31/12/2009 20:50',
     202            'time_field': u'20:50'
     203        })
     204        self.assertEqual(True, form3.is_valid())
     205        self.assertEqual(decimal.Decimal('66666.666'), form3.cleaned_data['decimal_field'])
     206        self.assertEqual(99999.999, form3.cleaned_data['float_field'])
     207        self.assertEqual(datetime.date(2009, 12, 31), form3.cleaned_data['date_field'])
     208        self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), form3.cleaned_data['datetime_field'])
     209        self.assertEqual(datetime.time(20, 50), form3.cleaned_data['time_field'])
     210
     211        form4 = SelectDateForm({
     212            'date_field_month': u'12',
     213            'date_field_day': u'31',
     214            'date_field_year': u'2009'
     215        })
     216        self.assertEqual(True, form4.is_valid())
     217        self.assertEqual(datetime.date(2009, 12, 31), form4.cleaned_data['date_field'])
     218        self.assertEqual(u'<select name="mydate_day" id="id_mydate_day">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_month" id="id_mydate_month">\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>', SelectDateWidget().render('mydate', datetime.date(2009, 12, 31)))
     219        deactivate()
     220
     221        # English locale
     222
     223        settings.USE_FORMAT_I18N = True
     224        activate('en')
     225        self.assertEqual('N j, Y', getformat('DATE_FORMAT'))
     226        self.assertEqual(0, getformat('FIRST_DAY_OF_WEEK'))
     227        self.assertEqual('.', getformat('DECIMAL_SEPARATOR'))
     228        self.assertEqual(u'Dec. 31, 2009', date_format(d))
     229        self.assertEqual(u'December 2009', date_format(d, 'YEAR_MONTH_FORMAT'))
     230        self.assertEqual(u'12/31/2009 8:50 p.m.', date_format(dt, 'SHORT_DATETIME_FORMAT'))
     231        self.assertEqual('No localizable', localize('No localizable'))
     232
     233        settings.USE_THOUSAND_SEPARATOR = True
     234        self.assertEqual(u'66,666.666', localize(n))
     235        self.assertEqual(u'99,999.999', localize(f))
     236
     237        settings.USE_THOUSAND_SEPARATOR = False
     238        self.assertEqual(u'66666.666', localize(n))
     239        self.assertEqual(u'99999.999', localize(f))
     240        self.assertEqual(u'Dec. 31, 2009', localize(d))
     241        self.assertEqual(u'Dec. 31, 2009, 8:50 p.m.', localize(dt))
     242
     243        settings.USE_THOUSAND_SEPARATOR = True
     244        self.assertEqual(u'66,666.666', template.Template('{{ n }}').render(ctxt))
     245        self.assertEqual(u'99,999.999', template.Template('{{ f }}').render(ctxt))
     246
     247        settings.USE_THOUSAND_SEPARATOR = False
     248        self.assertEqual(u'66666.666', template.Template('{{ n }}').render(ctxt))
     249        self.assertEqual(u'99999.999', template.Template('{{ f }}').render(ctxt))
     250        self.assertEqual(u'Dec. 31, 2009', template.Template('{{ d }}').render(ctxt))
     251        self.assertEqual(u'Dec. 31, 2009, 8:50 p.m.', template.Template('{{ dt }}').render(ctxt))
     252        self.assertEqual(u'66666.67', template.Template('{{ n|floatformat:2 }}').render(ctxt))
     253        self.assertEqual(u'100000.0', template.Template('{{ f|floatformat }}').render(ctxt))
     254        self.assertEqual(u'12/31/2009', template.Template('{{ d|date:"SHORT_DATE_FORMAT" }}').render(ctxt))
     255        self.assertEqual(u'12/31/2009 8:50 p.m.', template.Template('{{ dt|date:"SHORT_DATETIME_FORMAT" }}').render(ctxt))
     256
     257        form5 = I18nForm({
     258            'decimal_field': u'66666.666',
     259            'float_field': u'99999.999',
     260            'date_field': u'12/31/2009',
     261            'datetime_field': u'12/31/2009 20:50',
     262            'time_field': u'20:50'
     263        })
     264        self.assertEqual(True, form5.is_valid())
     265        self.assertEqual(decimal.Decimal('66666.666'), form5.cleaned_data['decimal_field'])
     266        self.assertEqual(99999.999, form5.cleaned_data['float_field'])
     267        self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field'])
     268        self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), form5.cleaned_data['datetime_field'])
     269        self.assertEqual(datetime.time(20, 50), form5.cleaned_data['time_field'])
     270
     271        form6 = SelectDateForm({
     272            'date_field_month': u'12',
     273            'date_field_day': u'31',
     274            'date_field_year': u'2009'
     275        })
     276        self.assertEqual(True, form6.is_valid())
     277        self.assertEqual(datetime.date(2009, 12, 31), form6.cleaned_data['date_field'])
     278        self.assertEqual(u'<select name="mydate_month" id="id_mydate_month">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12" selected="selected">December</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>', SelectDateWidget().render('mydate', datetime.date(2009, 12, 31)))
     279        deactivate()
     280
     281        # Check if long locales work
     282        activate('de-at')
     283        settings.USE_THOUSAND_SEPARATOR = True
     284        self.assertEqual(u'66.666,666', template.Template('{{ n }}').render(ctxt))
     285        deactivate()
     286
     287        # Restore defaults
     288        settings.USE_I18N = old_use_i18n
     289        settings.USE_FORMAT_I18N = old_use_format_i18n
     290        settings.USE_THOUSAND_SEPARATOR = old_use_thousand_separator
     291
     292
     293class MiscTests(TestCase):
     294
     295    def test_parse_spec_http_header(self):
     296        """
     297        Testing HTTP header parsing. First, we test that we can parse the
     298        values according to the spec (and that we extract all the pieces in
     299        the right order).
     300        """
     301        from django.utils.translation.trans_real import parse_accept_lang_header
     302        p = parse_accept_lang_header
     303        # Good headers.
     304        self.assertEqual([('de', 1.0)], p('de'))
     305        self.assertEqual([('en-AU', 1.0)], p('en-AU'))
     306        self.assertEqual([('*', 1.0)], p('*;q=1.00'))
     307        self.assertEqual([('en-AU', 0.123)], p('en-AU;q=0.123'))
     308        self.assertEqual([('en-au', 0.10000000000000001)], p('en-au;q=0.1'))
     309        self.assertEqual([('en-au', 1.0)], p('en-au;q=1.0'))
     310        self.assertEqual([('da', 1.0), ('en', 0.5), ('en-gb', 0.25)], p('da, en-gb;q=0.25, en;q=0.5'))
     311        self.assertEqual([('en-au-xx', 1.0)], p('en-au-xx'))
     312        self.assertEqual([('de', 1.0), ('en-au', 0.75), ('en-us', 0.5), ('en', 0.25), ('es', 0.125), ('fa', 0.125)], p('de,en-au;q=0.75,en-us;q=0.5,en;q=0.25,es;q=0.125,fa;q=0.125'))
     313        self.assertEqual([('*', 1.0)], p('*'))
     314        self.assertEqual([('de', 1.0)], p('de;q=0.'))
     315        self.assertEqual([], p(''))
     316
     317        # Bad headers; should always return [].
     318        self.assertEqual([], p('en-gb;q=1.0000'))
     319        self.assertEqual([], p('en;q=0.1234'))
     320        self.assertEqual([], p('en;q=.2'))
     321        self.assertEqual([], p('abcdefghi-au'))
     322        self.assertEqual([], p('**'))
     323        self.assertEqual([], p('en,,gb'))
     324        self.assertEqual([], p('en-au;q=0.1.0'))
     325        self.assertEqual([], p('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZ,en'))
     326        self.assertEqual([], p('da, en-gb;q=0.8, en;q=0.7,#'))
     327        self.assertEqual([], p('de;q=2.0'))
     328        self.assertEqual([], p('de;q=0.a'))
     329        self.assertEqual([], p(''))
     330
     331    def test_parse_literal_http_header(self):
     332        """
     333        Now test that we parse a literal HTTP header correctly.
     334        """
     335        from django.utils.translation.trans_real import get_language_from_request
     336        g = get_language_from_request
     337        from django.http import HttpRequest
     338        r = HttpRequest
     339        r.COOKIES = {}
     340        r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt-br'}
     341        self.assertEqual('pt-br', g(r))
     342
     343        r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt'}
     344        self.assertEqual('pt', g(r))
     345
     346        r.META = {'HTTP_ACCEPT_LANGUAGE': 'es,de'}
     347        self.assertEqual('es', g(r))
     348
     349        r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-ar,de'}
     350        self.assertEqual('es-ar', g(r))
     351
     352        # Python 2.3 and 2.4 return slightly different results for completely
     353        # bogus locales, so we omit this test for that anything below 2.4.
     354        # It's relatively harmless in any cases (GIGO). This also means this
     355        # won't be executed on Jython currently, but life's like that
     356        # sometimes. (On those platforms, passing in a truly bogus locale
     357        # will get you the default locale back.)
     358        if sys.version_info >= (2, 5):
     359            # This test assumes there won't be a Django translation to a US
     360            # variation of the Spanish language, a safe assumption. When the
     361            # user sets it as the preferred language, the main 'es'
     362            # translation should be selected instead.
     363            r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-us'}
     364            self.assertEqual(g(r), 'es')
     365
     366        # This tests the following scenario: there isn't a main language (zh)
     367        # translation of Django but there is a translation to variation (zh_CN)
     368        # the user sets zh-cn as the preferred language, it should be selected
     369        # by Django without falling back nor ignoring it.
     370        r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,de'}
     371        self.assertEqual(g(r), 'zh-cn')
Back to Top