Ticket #7980: i18n-formatting.5.diff

File i18n-formatting.5.diff, 146.9 KB (added by jezdez, 6 years ago)

More deprecation warnings and Renamed USE_FORMAT_I18N setting to USE_L10N

  • django/conf/global_settings.py

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

    diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py
    index e36b8a1..106964f 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_L10N:
     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 c0ee2f0..b7fafe7 100644
    a b import os 
    77import re
    88import time
    99import urlparse
     10import warnings
    1011from decimal import Decimal, DecimalException
    1112try:
    1213    from cStringIO import StringIO
    import django.core.exceptions 
    1718import django.utils.copycompat as copy
    1819from django.utils.translation import ugettext_lazy as _
    1920from django.utils.encoding import smart_unicode, smart_str
     21from django.utils.formats import getformat
    2022
    2123from util import ErrorList, ValidationError
    2224from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget
    __all__ = ( 
    3638# These values, if given to to_python(), will trigger the self.required check.
    3739EMPTY_VALUES = (None, '')
    3840
     41def en_format(name):
     42    """
     43    Helper function to stay backward compatible.
     44    """
     45    from django.conf.locale.en import formats
     46    warnings.warn(
     47        "`django.forms.fields.DEFAULT_%s` is deprecated; use `django.utils.formats.getformat('%s')` instead." % (name, name),
     48        PendingDeprecationWarning
     49    )
     50    return getattr(formats, name)
     51
     52DEFAULT_DATE_INPUT_FORMATS = en_format('DATE_INPUT_FORMATS')
     53DEFAULT_TIME_INPUT_FORMATS = en_format('TIME_INPUT_FORMATS')
     54DEFAULT_DATETIME_INPUT_FORMATS = en_format('DATETIME_INPUT_FORMATS')
    3955
    4056class Field(object):
    4157    widget = TextInput # Default widget to use when rendering this type of Field.
    class FloatField(Field): 
    200216        if not self.required and value in EMPTY_VALUES:
    201217            return None
    202218        try:
    203             value = float(value)
     219            # We always accept dot as decimal separator
     220            if isinstance(value, str) or isinstance(value, unicode):
     221                value = float(value.replace(getformat('DECIMAL_SEPARATOR'), '.'))
    204222        except (ValueError, TypeError):
    205223            raise ValidationError(self.error_messages['invalid'])
    206224        if self.max_value is not None and value > self.max_value:
    class DecimalField(Field): 
    236254            return None
    237255        value = smart_str(value).strip()
    238256        try:
    239             value = Decimal(value)
     257            # We always accept dot as decimal separator
     258            if isinstance(value, str) or isinstance(value, unicode):
     259                value = Decimal(value.replace(getformat('DECIMAL_SEPARATOR'), '.'))
    240260        except DecimalException:
    241261            raise ValidationError(self.error_messages['invalid'])
    242262
    class DecimalField(Field): 
    264284            raise ValidationError(self.error_messages['max_whole_digits'] % (self.max_digits - self.decimal_places))
    265285        return value
    266286
    267 DEFAULT_DATE_INPUT_FORMATS = (
    268     '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
    269     '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006'
    270     '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
    271     '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006'
    272     '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006'
    273 )
    274 
    275287class DateField(Field):
    276288    widget = DateInput
    277289    default_error_messages = {
    class DateField(Field): 
    280292
    281293    def __init__(self, input_formats=None, *args, **kwargs):
    282294        super(DateField, self).__init__(*args, **kwargs)
    283         self.input_formats = input_formats or DEFAULT_DATE_INPUT_FORMATS
     295        self.input_formats = input_formats
    284296
    285297    def clean(self, value):
    286298        """
    class DateField(Field): 
    294306            return value.date()
    295307        if isinstance(value, datetime.date):
    296308            return value
    297         for format in self.input_formats:
     309        for format in self.input_formats or getformat('DATE_INPUT_FORMATS'):
    298310            try:
    299311                return datetime.date(*time.strptime(value, format)[:3])
    300312            except ValueError:
    301313                continue
    302314        raise ValidationError(self.error_messages['invalid'])
    303315
    304 DEFAULT_TIME_INPUT_FORMATS = (
    305     '%H:%M:%S',     # '14:30:59'
    306     '%H:%M',        # '14:30'
    307 )
    308 
    309316class TimeField(Field):
    310317    widget = TimeInput
    311318    default_error_messages = {
    class TimeField(Field): 
    314321
    315322    def __init__(self, input_formats=None, *args, **kwargs):
    316323        super(TimeField, self).__init__(*args, **kwargs)
    317         self.input_formats = input_formats or DEFAULT_TIME_INPUT_FORMATS
     324        self.input_formats = input_formats
    318325
    319326    def clean(self, value):
    320327        """
    class TimeField(Field): 
    326333            return None
    327334        if isinstance(value, datetime.time):
    328335            return value
    329         for format in self.input_formats:
     336        for format in self.input_formats or getformat('TIME_INPUT_FORMATS'):
    330337            try:
    331338                return datetime.time(*time.strptime(value, format)[3:6])
    332339            except ValueError:
    333340                continue
    334341        raise ValidationError(self.error_messages['invalid'])
    335342
    336 DEFAULT_DATETIME_INPUT_FORMATS = (
    337     '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
    338     '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
    339     '%Y-%m-%d',              # '2006-10-25'
    340     '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
    341     '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
    342     '%m/%d/%Y',              # '10/25/2006'
    343     '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
    344     '%m/%d/%y %H:%M',        # '10/25/06 14:30'
    345     '%m/%d/%y',              # '10/25/06'
    346 )
    347 
    348343class DateTimeField(Field):
    349344    widget = DateTimeInput
    350345    default_error_messages = {
    class DateTimeField(Field): 
    353348
    354349    def __init__(self, input_formats=None, *args, **kwargs):
    355350        super(DateTimeField, self).__init__(*args, **kwargs)
    356         self.input_formats = input_formats or DEFAULT_DATETIME_INPUT_FORMATS
     351        self.input_formats = input_formats
    357352
    358353    def clean(self, value):
    359354        """
    class DateTimeField(Field): 
    373368            if len(value) != 2:
    374369                raise ValidationError(self.error_messages['invalid'])
    375370            value = '%s %s' % tuple(value)
    376         for format in self.input_formats:
     371        for format in self.input_formats or getformat('DATETIME_INPUT_FORMATS'):
    377372            try:
    378373                return datetime.datetime(*time.strptime(value, format)[:6])
    379374            except ValueError:
  • django/forms/widgets.py

    diff --git a/django/forms/widgets.py b/django/forms/widgets.py
    index d59e634..aabd1b0 100644
    a b from django.utils.html import escape, conditional_escape 
    1010from django.utils.translation import ugettext
    1111from django.utils.encoding import StrAndUnicode, force_unicode
    1212from django.utils.safestring import mark_safe
     13from django.utils.formats import localize
    1314from django.utils import datetime_safe
    1415from datetime import time
    1516from util import flatatt
    class Input(Widget): 
    208209        final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
    209210        if value != '':
    210211            # Only add the 'value' attribute if a value is non-empty.
    211             final_attrs['value'] = force_unicode(value)
     212            final_attrs['value'] = force_unicode(localize(value, is_input=True))
    212213        return mark_safe(u'<input%s />' % flatatt(final_attrs))
    213214
    214215class 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..2238b4e
    - +  
     1import decimal
     2import datetime
     3
     4from django.conf import settings
     5from django.utils.translation import get_language, to_locale, check_for_language
     6from django.utils.importlib import import_module
     7from django.utils import dateformat
     8from django.utils import numberformat
     9
     10def get_format_modules():
     11    """
     12    Returns an iterator over the format modules found in the project and Django
     13    """
     14    modules = []
     15    if not check_for_language(get_language()):
     16        return modules
     17    locale = to_locale(get_language())
     18    if settings.FORMAT_MODULE_PATH:
     19        format_locations = [settings.FORMAT_MODULE_PATH + '.%s']
     20    else:
     21        format_locations = []
     22    format_locations.append('django.conf.locale.%s')
     23    for location in format_locations:
     24        for l in (locale, locale.split('_')[0]):
     25            try:
     26                mod = import_module('.formats', location % l)
     27            except ImportError:
     28                pass
     29            else:
     30                # Don't return duplicates
     31                if mod not in modules:
     32                    modules.append(mod)
     33    return modules
     34
     35def getformat(format_type):
     36    """
     37    For a specific format type, returns the format for the
     38    current language (locale) defaulting to the format on settings.
     39    format_type is the name of the format, for example 'DATE_FORMAT'
     40    """
     41    if settings.USE_L10N:
     42        for module in get_format_modules():
     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_L10N:
     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..50f41a2 100644
    a b  
    22# that don't actually do anything. This is purely for performance, so that
    33# settings.USE_I18N = False can use this module rather than trans_real.py.
    44
     5import warnings
    56from django.conf import settings
    67from django.utils.encoding import force_unicode
    78from django.utils.safestring import mark_safe, SafeData
    activate = lambda x: None 
    1819deactivate = deactivate_all = lambda: None
    1920get_language = lambda: settings.LANGUAGE_CODE
    2021get_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)
    2322check_for_language = lambda x: True
    2423
     24# date formats shouldn't be used using gettext anymore. This
     25# is kept for backward compatibility
    2526TECHNICAL_ID_MAP = {
    2627    "DATE_WITH_TIME_FULL": settings.DATETIME_FORMAT,
    2728    "DATE_FORMAT": settings.DATE_FORMAT,
    def to_locale(language): 
    5152
    5253def get_language_from_request(request):
    5354    return settings.LANGUAGE_CODE
     55
     56# get_date_formats and get_partial_date_formats aren't used anymore by Django
     57# but are kept for backward compatibility.
     58def get_date_formats():
     59    warnings.warn(
     60        '`django.utils.translation.get_date_formats` is deprecated. '
     61        'Please update your code to use the new i18n aware formatting.',
     62        PendingDeprecationWarning
     63    )
     64    return settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT
     65
     66def get_partial_date_formats():
     67    warnings.warn(
     68        '`django.utils.translation.get_partial_date_formats` is deprecated. '
     69        'Please update your code to use the new i18n aware formatting.',
     70        PendingDeprecationWarning
     71    )
     72    return 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..8b7db0f 100644
    a b import locale 
    44import os
    55import re
    66import sys
     7import warnings
    78import gettext as gettext_module
    89from cStringIO import StringIO
    910
    def do_translate(message, translation_function): 
    266267    translation object to use. If no current translation is activated, the
    267268    message will be run through the default translation object.
    268269    """
     270    eol_message = message.replace('\r\n', '\n').replace('\r', '\n')
    269271    global _default, _active
    270272    t = _active.get(currentThread(), None)
    271273    if t is not None:
    272         result = getattr(t, translation_function)(message)
     274        result = getattr(t, translation_function)(eol_message)
    273275    else:
    274276        if _default is None:
    275277            from django.conf import settings
    276278            _default = translation(settings.LANGUAGE_CODE)
    277         result = getattr(_default, translation_function)(message)
     279        result = getattr(_default, translation_function)(eol_message)
    278280    if isinstance(message, SafeData):
    279281        return mark_safe(result)
    280282    return result
    def get_language_from_request(request): 
    389391
    390392    return settings.LANGUAGE_CODE
    391393
    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 
    425394dot_re = re.compile(r'\S')
    426395def blankout(src, char):
    427396    """
    def parse_accept_lang_header(lang_string): 
    537506        result.append((lang, priority))
    538507    result.sort(lambda x, y: -cmp(x[1], y[1]))
    539508    return result
     509
     510# get_date_formats and get_partial_date_formats aren't used anymore by Django
     511# and are kept for backward compatibility.
     512# Note, it's also important to keep format names marked for translation.
     513# For compatibility we still want to have formats on translation catalogs.
     514# That makes template code like {{ my_date|date:_('DATE_FORMAT') }} still work
     515def get_date_formats():
     516    """
     517    Checks whether translation files provide a translation for some technical
     518    message ID to store date and time formats. If it doesn't contain one, the
     519    formats provided in the settings will be used.
     520    """
     521    warnings.warn(
     522        '`django.utils.translation.get_date_formats` is deprecated. '
     523        'Please update your code to use the new i18n aware formatting.',
     524        PendingDeprecationWarning
     525    )
     526    from django.conf import settings
     527    date_format = ugettext('DATE_FORMAT')
     528    datetime_format = ugettext('DATETIME_FORMAT')
     529    time_format = ugettext('TIME_FORMAT')
     530    if date_format == 'DATE_FORMAT':
     531        date_format = settings.DATE_FORMAT
     532    if datetime_format == 'DATETIME_FORMAT':
     533        datetime_format = settings.DATETIME_FORMAT
     534    if time_format == 'TIME_FORMAT':
     535        time_format = settings.TIME_FORMAT
     536    return date_format, datetime_format, time_format
     537
     538def get_partial_date_formats():
     539    """
     540    Checks whether translation files provide a translation for some technical
     541    message ID to store partial date formats. If it doesn't contain one, the
     542    formats provided in the settings will be used.
     543    """
     544    warnings.warn(
     545        '`django.utils.translation.get_partial_date_formats` is deprecated. '
     546        'Please update your code to use the new i18n aware formatting.',
     547        PendingDeprecationWarning
     548    )
     549    from django.conf import settings
     550    year_month_format = ugettext('YEAR_MONTH_FORMAT')
     551    month_day_format = ugettext('MONTH_DAY_FORMAT')
     552    if year_month_format == 'YEAR_MONTH_FORMAT':
     553        year_month_format = settings.YEAR_MONTH_FORMAT
     554    if month_day_format == 'MONTH_DAY_FORMAT':
     555        month_day_format = settings.MONTH_DAY_FORMAT
     556    return year_month_format, month_day_format
     557
  • django/views/i18n.py

    diff --git a/django/views/i18n.py b/django/views/i18n.py
    index 0280698..ddd7520 100644
    a b  
     1import os
     2import gettext as gettext_module
     3
    14from django import http
    25from django.conf import settings
    36from django.utils import importlib
    47from django.utils.translation import check_for_language, activate, to_locale, get_language
    58from django.utils.text import javascript_quote
    6 import os
    7 import gettext as gettext_module
     9from django.utils.formats import get_format_modules
    810
    911def set_language(request):
    1012    """
    def set_language(request): 
    3234                response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
    3335    return response
    3436
     37def get_formats():
     38    """
     39    Returns an iterator over all formats in formats file
     40    """
     41    FORMAT_SETTINGS = ('DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT',
     42        'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 'SHORT_DATE_FORMAT',
     43        'SHORT_DATETIME_FORMAT', 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR',
     44        'THOUSAND_SEPARATOR', 'NUMBER_GROUPING')
     45
     46    result = {}
     47    for module in [settings] + get_format_modules():
     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..9b32ff7 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_L10N`` 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_L10N`` 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_L10N`` 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_L10N`` 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_L10N`` 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_L10N
     1462
     1463USE_L10N
     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_L10N``
     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_L10N`` 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..ab25a0f 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_L10N = True <USE_L10N>` in your settings file. If
     35:settings:`USE_L10N` 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_L10N = True <USE_L10N>` in your settings
     1090file.  Note that :setting:`USE_L10N` 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..912d7cb 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_l10n = settings.USE_L10N
     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_L10N = 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_L10N = 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_L10N = 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_L10N = 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 sublocales fall back to the main locale
     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        activate('es-ar')
     288        self.assertEqual(u'31 de Diciembre de 2009', date_format(d))
     289        deactivate()
     290
     291        # Restore defaults
     292        settings.USE_I18N = old_use_i18n
     293        settings.USE_L10N = old_use_l10n
     294        settings.USE_THOUSAND_SEPARATOR = old_use_thousand_separator
     295
     296
     297class MiscTests(TestCase):
     298
     299    def test_parse_spec_http_header(self):
     300        """
     301        Testing HTTP header parsing. First, we test that we can parse the
     302        values according to the spec (and that we extract all the pieces in
     303        the right order).
     304        """
     305        from django.utils.translation.trans_real import parse_accept_lang_header
     306        p = parse_accept_lang_header
     307        # Good headers.
     308        self.assertEqual([('de', 1.0)], p('de'))
     309        self.assertEqual([('en-AU', 1.0)], p('en-AU'))
     310        self.assertEqual([('*', 1.0)], p('*;q=1.00'))
     311        self.assertEqual([('en-AU', 0.123)], p('en-AU;q=0.123'))
     312        self.assertEqual([('en-au', 0.10000000000000001)], p('en-au;q=0.1'))
     313        self.assertEqual([('en-au', 1.0)], p('en-au;q=1.0'))
     314        self.assertEqual([('da', 1.0), ('en', 0.5), ('en-gb', 0.25)], p('da, en-gb;q=0.25, en;q=0.5'))
     315        self.assertEqual([('en-au-xx', 1.0)], p('en-au-xx'))
     316        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'))
     317        self.assertEqual([('*', 1.0)], p('*'))
     318        self.assertEqual([('de', 1.0)], p('de;q=0.'))
     319        self.assertEqual([], p(''))
     320
     321        # Bad headers; should always return [].
     322        self.assertEqual([], p('en-gb;q=1.0000'))
     323        self.assertEqual([], p('en;q=0.1234'))
     324        self.assertEqual([], p('en;q=.2'))
     325        self.assertEqual([], p('abcdefghi-au'))
     326        self.assertEqual([], p('**'))
     327        self.assertEqual([], p('en,,gb'))
     328        self.assertEqual([], p('en-au;q=0.1.0'))
     329        self.assertEqual([], p('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZ,en'))
     330        self.assertEqual([], p('da, en-gb;q=0.8, en;q=0.7,#'))
     331        self.assertEqual([], p('de;q=2.0'))
     332        self.assertEqual([], p('de;q=0.a'))
     333        self.assertEqual([], p(''))
     334
     335    def test_parse_literal_http_header(self):
     336        """
     337        Now test that we parse a literal HTTP header correctly.
     338        """
     339        from django.utils.translation.trans_real import get_language_from_request
     340        g = get_language_from_request
     341        from django.http import HttpRequest
     342        r = HttpRequest
     343        r.COOKIES = {}
     344        r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt-br'}
     345        self.assertEqual('pt-br', g(r))
     346
     347        r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt'}
     348        self.assertEqual('pt', g(r))
     349
     350        r.META = {'HTTP_ACCEPT_LANGUAGE': 'es,de'}
     351        self.assertEqual('es', g(r))
     352
     353        r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-ar,de'}
     354        self.assertEqual('es-ar', g(r))
     355
     356        # Python 2.3 and 2.4 return slightly different results for completely
     357        # bogus locales, so we omit this test for that anything below 2.4.
     358        # It's relatively harmless in any cases (GIGO). This also means this
     359        # won't be executed on Jython currently, but life's like that
     360        # sometimes. (On those platforms, passing in a truly bogus locale
     361        # will get you the default locale back.)
     362        if sys.version_info >= (2, 5):
     363            # This test assumes there won't be a Django translation to a US
     364            # variation of the Spanish language, a safe assumption. When the
     365            # user sets it as the preferred language, the main 'es'
     366            # translation should be selected instead.
     367            r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-us'}
     368            self.assertEqual(g(r), 'es')
     369
     370        # This tests the following scenario: there isn't a main language (zh)
     371        # translation of Django but there is a translation to variation (zh_CN)
     372        # the user sets zh-cn as the preferred language, it should be selected
     373        # by Django without falling back nor ignoring it.
     374        r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,de'}
     375        self.assertEqual(g(r), 'zh-cn')
Back to Top