Ticket #7980: i18n-formatting.4.diff
File i18n-formatting.4.diff, 146.3 KB (added by , 15 years ago) |
---|
-
django/conf/global_settings.py
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 828aef5..b2b6963 100644
a b USE_I18N = True 103 103 LOCALE_PATHS = () 104 104 LANGUAGE_COOKIE_NAME = 'django_language' 105 105 106 # If you set this to True, Django will format dates, numbers and calendars 107 # according to user current locale 108 USE_FORMAT_I18N = False 109 106 110 # Not-necessarily-technical managers of the site. They get broken link 107 111 # notifications and other various e-mails. 108 112 MANAGERS = ADMINS … … FILE_UPLOAD_TEMP_DIR = None 262 266 # you'd pass directly to os.chmod; see http://docs.python.org/lib/os-file-dir.html. 263 267 FILE_UPLOAD_PERMISSIONS = None 264 268 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) 273 FORMAT_MODULE_PATH = None 274 265 275 # Default formatting for date objects. See all available format strings here: 266 276 # http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now 267 277 DATE_FORMAT = 'N j, Y' … … YEAR_MONTH_FORMAT = 'F Y' 284 294 # http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now 285 295 MONTH_DAY_FORMAT = 'F j' 286 296 297 # Default shortformatting for date objects. See all available format strings here: 298 # http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now 299 SHORT_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 304 SHORT_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 311 DATE_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 324 TIME_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 334 DATETIME_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... 348 FIRST_DAY_OF_WEEK = 0 349 350 # Decimal separator symbol 351 DECIMAL_SEPARATOR = '.' 352 353 # Boolean that sets whether to add thousand separator when formatting numbers 354 USE_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... 358 NUMBER_GROUPING = 0 359 360 # Thousand separator symbol 361 THOUSAND_SEPARATOR = ',' 362 287 363 # Do you want to manage transactions manually? 288 364 # Hint: you really don't! 289 365 TRANSACTIONS_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 5 DATE_FORMAT = 'j F، Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F, Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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/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 5 DATE_FORMAT = 'j \de F \de Y' 6 TIME_FORMAT = 'G:i:s' 7 DATETIME_FORMAT = 'j \de F \de Y \\a \le\s G:i' 8 YEAR_MONTH_FORMAT = 'F \de\l Y' 9 MONTH_DAY_FORMAT = 'j \de F' 10 SHORT_DATE_FORMAT = 'd/m/Y' 11 SHORT_DATETIME_FORMAT = 'd/m/Y G:i' 12 FIRST_DAY_OF_WEEK = 1 # Monday 13 DATE_INPUT_FORMATS = ( 14 # '31/12/2009', '31/12/09' 15 '%d/%m/%Y', '%d/%m/%y' 16 ) 17 TIME_INPUT_FORMATS = ( 18 # '14:30:59', '14:30' 19 '%H:%M:%S', '%H:%M' 20 ) 21 DATETIME_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 ) 27 DECIMAL_SEPARATOR = ',' 28 THOUSAND_SEPARATOR = '.' 29 NUMBER_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 5 DATE_FORMAT = 'j. F Y' 6 TIME_FORMAT = 'G:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 # MONTH_DAY_FORMAT = 10 SHORT_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 5 DATE_FORMAT = 'j. F Y' 6 TIME_FORMAT = 'H:i' 7 DATETIME_FORMAT = 'j. F Y H:i' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_DATE_FORMAT = 'd.m.Y' 11 SHORT_DATETIME_FORMAT = 'd.m.Y H:i' 12 FIRST_DAY_OF_WEEK = 1 13 DATE_INPUT_FORMATS = ( 14 '%d.%m.%Y', # '25.10.2006' 15 ) 16 TIME_INPUT_FORMATS = ( 17 '%H:%M:%S', # '14:30:59' 18 '%H:%M', # '14:30' 19 ) 20 DATETIME_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 ) 24 DECIMAL_SEPARATOR = ',' 25 THOUSAND_SEPARATOR = '.' 26 NUMBER_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 5 DATE_FORMAT = 'j. F Y' 6 TIME_FORMAT = 'H:i:s' 7 DATETIME_FORMAT = 'j. F Y H:i:s' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_DATE_FORMAT = 'd.m.Y' 11 SHORT_DATETIME_FORMAT = 'd.m.Y H:i:s' 12 FIRST_DAY_OF_WEEK = 1 # Monday 13 DATE_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 ) 18 TIME_INPUT_FORMATS = ( 19 '%H:%M:%S', # '14:30:59' 20 '%H:%M', # '14:30' 21 ) 22 DATETIME_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 ) 30 DECIMAL_SEPARATOR = ',' 31 THOUSAND_SEPARATOR = '.' 32 NUMBER_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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'N j, Y' 6 TIME_FORMAT = 'P' 7 DATETIME_FORMAT = 'N j, Y, P' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'F j' 10 SHORT_DATE_FORMAT = 'm/d/Y' 11 SHORT_DATETIME_FORMAT = 'm/d/Y P' 12 FIRST_DAY_OF_WEEK = 0 # Sunday 13 DATE_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 ) 20 TIME_INPUT_FORMATS = ( 21 '%H:%M:%S', # '14:30:59' 22 '%H:%M', # '14:30' 23 ) 24 DATETIME_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 ) 35 DECIMAL_SEPARATOR = '.' 36 THOUSAND_SEPARATOR = ',' 37 NUMBER_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 5 DATE_FORMAT = 'j \de F \de Y' 6 TIME_FORMAT = 'H:i:s' 7 DATETIME_FORMAT = 'j \de F \de Y \a \l\a\s H:i' 8 YEAR_MONTH_FORMAT = 'F \de Y' 9 MONTH_DAY_FORMAT = 'j \de F' 10 SHORT_DATE_FORMAT = 'd/m/Y' 11 SHORT_DATETIME_FORMAT = 'd/m/Y H:i' 12 FIRST_DAY_OF_WEEK = 1 # Monday 13 DATE_INPUT_FORMATS = ( 14 # '31/12/2009', '31/12/09' 15 '%d/%m/%Y', '%d/%m/%y' 16 ) 17 TIME_INPUT_FORMATS = ( 18 # '14:30:59', '14:30' 19 '%H:%M:%S', '%H:%M' 20 ) 21 DATETIME_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 ) 27 DECIMAL_SEPARATOR = ',' 28 THOUSAND_SEPARATOR = '.' 29 NUMBER_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'G:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'Yeko M\re\n d\a' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 # MONTH_DAY_FORMAT = 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'G:i:s' 7 DATETIME_FORMAT = 'j F Y، ساعت G:i:s' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_DATE_FORMAT = 'Y/n/j' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j. F Y' 6 TIME_FORMAT = 'G.i.s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'H:i:s' 7 DATETIME_FORMAT = 'j F Y H:i:s' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_DATE_FORMAT = 'j M Y' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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/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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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/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 5 DATE_FORMAT = 'j בF Y' 6 TIME_FORMAT = 'H:i:s' 7 DATETIME_FORMAT = 'j בF Y H:i:s' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j בF' 10 SHORT_DATE_FORMAT = 'd/m/Y' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = '.' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = '.' 17 THOUSAND_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 5 DATE_FORMAT = 'j. F Y.' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y.' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'Y. F j.' 6 TIME_FORMAT = 'G:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'F j.' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j. F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'H.i.s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'Y年n月j日' 6 TIME_FORMAT = 'G:i:s' 7 DATETIME_FORMAT = 'Y年n月j日G:i:s' 8 YEAR_MONTH_FORMAT = 'Y年n月' 9 MONTH_DAY_FORMAT = 'n月j日' 10 SHORT_DATE_FORMAT = 'Y/m/d' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = '.' 17 THOUSAND_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 5 DATE_FORMAT = 'l, j F, Y' 6 TIME_FORMAT = 'h:i:s a' 7 DATETIME_FORMAT = 'j F, Y h:i:s a' 8 YEAR_MONTH_FORMAT = 'F, Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_DATE_FORMAT = 'j.M.Y' 11 SHORT_DATETIME_FORMAT = 'j.M.Y H:i:s' 12 FIRST_DAY_OF_WEEK = 1 # (Monday) 13 DATE_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 ) 19 TIME_INPUT_FORMATS = ( 20 '%H:%M:%S', # '14:30:59' 21 '%H:%M', # '14:30' 22 ) 23 DATETIME_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 ) 40 DECIMAL_SEPARATOR = '.' 41 THOUSAND_SEPARATOR = " " 42 NUMBER_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 5 DATE_FORMAT = 'j ខែ F ឆ្នាំ Y' 6 TIME_FORMAT = 'G:i:s' 7 DATETIME_FORMAT = 'j ខែ F ឆ្នាំ Y, G:i:s' 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_DATE_FORMAT = 'j M Y' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'h:i:s A' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 5 DATE_FORMAT = 'Y년 n월 j일' 6 TIME_FORMAT = 'A g:i:s' 7 DATETIME_FORMAT = 'Y년 n월 j일 g:i:s A' 8 YEAR_MONTH_FORMAT = 'Y년 F월' 9 MONTH_DAY_FORMAT = 'F월 j일' 10 SHORT_DATE_FORMAT = 'Y-n-j.' 11 SHORT_DATETIME_FORMAT = 'Y-n-j H:i' 12 # FIRST_DAY_OF_WEEK = 13 DATE_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 ) 21 TIME_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 ) 27 DATETIME_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 42 DECIMAL_SEPARATOR = '.' 43 THOUSAND_SEPARATOR = ',' 44 NUMBER_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 5 DATE_FORMAT = 'Y \m. F j \d.' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 # MONTH_DAY_FORMAT = 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'Y. \g\a\d\a j. F' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'Y. \g. F' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 # MONTH_DAY_FORMAT = 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y' # '20 januari 2009' 6 TIME_FORMAT = 'H:i' # '15:23' 7 DATETIME_FORMAT = 'j F Y H:i' # '20 januari 2009 15:23' 8 YEAR_MONTH_FORMAT = 'F Y' # 'januari 2009' 9 MONTH_DAY_FORMAT = 'j F' # '20 januari' 10 SHORT_DATE_FORMAT = 'j-n-Y' # '20-1-2009' 11 SHORT_DATETIME_FORMAT = 'j-n-Y H:i' # '20-1-2009 15:23' 12 FIRST_DAY_OF_WEEK = 1 # Monday (in Dutch 'maandag') 13 DATE_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 ) 18 TIME_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 ) 24 DATETIME_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 ) 46 DECIMAL_SEPARATOR = ',' 47 THOUSAND_SEPARATOR = '.' 48 NUMBER_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
- + 1 DATE_FORMAT = 'j. F Y' 2 TIME_FORMAT = 'H:i' 3 DATETIME_FORMAT = 'j. F Y H:i' 4 YEAR_MONTH_FORMAT = 'F Y' 5 MONTH_DAY_FORMAT = 'j. F' 6 SHORT_DATE_FORMAT = 'd.m.Y' 7 SHORT_DATETIME_FORMAT = 'd.m.Y H:i' 8 FIRST_DAY_OF_WEEK = 1 # Monday 9 DATE_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 ) 16 TIME_INPUT_FORMATS = ( 17 '%H:%i:%S', # '14:30:59' 18 '%H:%i', # '14:30' 19 ) 20 DATETIME_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 ) 32 DECIMAL_SEPARATOR = ',' 33 THOUSAND_SEPARATOR = ' ' 34 NUMBER_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j \de F \de Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F \de Y' 9 MONTH_DAY_FORMAT = 'j \de F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j \\de N \\de Y' 6 TIME_FORMAT = 'H:i' 7 DATETIME_FORMAT = 'j \\de N \\de Y à\\s H:i' 8 YEAR_MONTH_FORMAT = 'F \\de Y' 9 MONTH_DAY_FORMAT = 'j \\de F' 10 SHORT_DATE_FORMAT = 'd/m/Y' 11 SHORT_DATETIME_FORMAT = 'd/m/Y H:i' 12 FIRST_DAY_OF_WEEK = 0 # Sunday 13 DATE_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 ) 18 TIME_INPUT_FORMATS = ( 19 '%H:%M:%S', # '14:30:59' 20 '%H:%M', # '14:30' 21 ) 22 DATETIME_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 ) 33 DECIMAL_SEPARATOR = ',' 34 THOUSAND_SEPARATOR = '.' 35 NUMBER_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'H:i:s' 7 DATETIME_FORMAT = 'j F Y, H:i:s' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_DATE_FORMAT = 'd.m.Y' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y г.' 6 TIME_FORMAT = 'G:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j. F Y' 6 TIME_FORMAT = 'G:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'd. F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_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/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 5 DATE_FORMAT = 'j. F Y.' 6 TIME_FORMAT = 'H:i' 7 DATETIME_FORMAT = 'j. F Y. H:i' 8 YEAR_MONTH_FORMAT = 'F Y.' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_DATE_FORMAT = 'j.m.Y.' 11 SHORT_DATETIME_FORMAT = 'j.m.Y. H:i' 12 FIRST_DAY_OF_WEEK = 1 13 DATE_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 ) 21 TIME_INPUT_FORMATS = ( 22 '%H:%M:%S', # '14:30:59' 23 '%H:%M', # '14:30' 24 ) 25 DATETIME_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 ) 42 DECIMAL_SEPARATOR = '.' 43 THOUSAND_SEPARATOR = ',' 44 NUMBER_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 5 DATE_FORMAT = 'j. F Y.' 6 TIME_FORMAT = 'H:i' 7 DATETIME_FORMAT = 'j. F Y. H:i' 8 YEAR_MONTH_FORMAT = 'F Y.' 9 MONTH_DAY_FORMAT = 'j. F' 10 SHORT_DATE_FORMAT = 'j.m.Y.' 11 SHORT_DATETIME_FORMAT = 'j.m.Y. H:i' 12 FIRST_DAY_OF_WEEK = 1 13 DATE_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 ) 21 TIME_INPUT_FORMATS = ( 22 '%H:%M:%S', # '14:30:59' 23 '%H:%M', # '14:30' 24 ) 25 DATETIME_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 ) 42 DECIMAL_SEPARATOR = '.' 43 THOUSAND_SEPARATOR = ',' 44 NUMBER_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'H.i.s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'Y F' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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/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 5 DATE_FORMAT = 'j F, Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'g:i:s A' 7 # DATETIME_FORMAT = 8 # YEAR_MONTH_FORMAT = 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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 5 DATE_FORMAT = 'j F Y' 6 TIME_FORMAT = 'G:i:s' 7 DATETIME_FORMAT = 'j F Y, G:i:s' 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_DATE_FORMAT = 'j M Y' 11 SHORT_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 = 16 DECIMAL_SEPARATOR = '.' 17 THOUSAND_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 5 DATE_FORMAT = 'd F Y' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'd F' 10 SHORT_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 = 16 DECIMAL_SEPARATOR = ',' 17 THOUSAND_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 5 DATE_FORMAT = 'j F Y р.' 6 TIME_FORMAT = 'H:i:s' 7 # DATETIME_FORMAT = 8 YEAR_MONTH_FORMAT = 'F Y' 9 MONTH_DAY_FORMAT = 'j F' 10 SHORT_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/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() { 25 25 var CalendarNamespace = { 26 26 monthsOfYear: gettext('January February March April May June July August September October November December').split(' '), 27 27 daysOfWeek: gettext('S M T W T F S').split(' '), 28 firstDayOfWeek: parseInt(gettext('FIRST_DAY_OF_WEEK')), 28 29 isLeapYear: function(year) { 29 30 return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)); 30 31 }, … … var CalendarNamespace = { 56 57 // Draw days-of-week header 57 58 var tableRow = quickElement('tr', tableBody); 58 59 for (var i = 0; i < 7; i++) { 59 quickElement('th', tableRow, CalendarNamespace.daysOfWeek[ i]);60 quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]); 60 61 } 61 62 62 var startingPos = new Date(year, month-1, 1 ).getDay();63 var startingPos = new Date(year, month-1, 1 - CalendarNamespace.firstDayOfWeek).getDay(); 63 64 var days = CalendarNamespace.getDaysInMonth(month, year); 64 65 65 66 // 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 27 27 <tbody> 28 28 {% for action in action_list %} 29 29 <tr> 30 <th scope="row">{{ action.action_time|date :_("DATETIME_FORMAT")}}</th>30 <th scope="row">{{ action.action_time|date }}</th> 31 31 <td>{{ action.user.username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td> 32 32 <td>{{ action.change_message }}</td> 33 33 </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 3 3 from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR 4 4 from django.core.exceptions import ObjectDoesNotExist 5 5 from django.db import models 6 from django.utils import dateformat6 from django.utils import formats 7 7 from django.utils.html import escape, conditional_escape 8 8 from django.utils.text import capfirst 9 9 from django.utils.safestring import mark_safe 10 from django.utils.translation import get_date_formats, get_partial_date_formats,ugettext as _10 from django.utils.translation import ugettext as _ 11 11 from django.utils.encoding import smart_unicode, smart_str, force_unicode 12 12 from django.template import Library 13 13 import datetime … … def items_for_result(cl, result, form): 189 189 # Dates and times are special: They're formatted in a certain way. 190 190 elif isinstance(f, models.DateField) or isinstance(f, models.TimeField): 191 191 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) 199 204 else: 200 205 result_repr = EMPTY_CHANGELIST_VALUE 201 206 row_class = ' class="nowrap"' 202 207 # Booleans are special: We use images. 203 208 elif isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField): 204 209 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_val209 else:210 result_repr = EMPTY_CHANGELIST_VALUE211 210 # Fields with choices are special: Use the representation 212 211 # of the choice. 213 212 elif f.flatchoices: … … def date_hierarchy(cl): 268 267 year_lookup = cl.params.get(year_field) 269 268 month_lookup = cl.params.get(month_field) 270 269 day_lookup = cl.params.get(day_field) 271 year_month_format, month_day_format = get_partial_date_formats()272 270 273 271 link = lambda d: cl.get_query_string(d, [field_generic]) 274 272 … … def date_hierarchy(cl): 278 276 'show': True, 279 277 'back': { 280 278 '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')) 282 280 }, 283 'choices': [{'title': dateformat.format(day, month_day_format)}]281 'choices': [{'title': capfirst(formats.date_format(day, 'MONTH_DAY_FORMAT'))}] 284 282 } 285 283 elif year_lookup and month_lookup: 286 284 days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day') … … def date_hierarchy(cl): 292 290 }, 293 291 'choices': [{ 294 292 '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')) 296 294 } for day in days] 297 295 } 298 296 elif year_lookup: … … def date_hierarchy(cl): 305 303 }, 306 304 'choices': [{ 307 305 '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')) 309 307 } for month in months] 310 308 } 311 309 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. 4 4 """ 5 5 6 6 from django.db import models 7 from django.utils import dateformat7 from django.utils import formats 8 8 from django.utils.text import capfirst 9 from django.utils.translation import get_date_formats10 9 from django.utils.encoding import smart_unicode, smart_str, iri_to_uri 11 10 from django.utils.safestring import mark_safe 12 11 from django.db.models.query import QuerySet … … class EasyInstanceField(object): 156 155 objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE) 157 156 elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField): 158 157 if self.raw_value: 159 date_format, datetime_format, time_format = get_date_formats()160 158 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')) 162 160 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')) 164 162 else: 165 objs = capfirst( dateformat.format(self.raw_value, date_format))163 objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT')) 166 164 else: 167 165 objs = EMPTY_VALUE 168 166 elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField): -
new file django/core/management/commands/importcldr.py
diff --git a/django/core/management/commands/importcldr.py b/django/core/management/commands/importcldr.py new file mode 100644 index 0000000..c4a13e6
- + 1 import sys 2 import os 3 import re 4 from optparse import make_option, OptionParser 5 6 from django.core.management.base import LabelCommand, CommandError 7 8 try: 9 from lxml import etree 10 except ImportError: 11 raise CommandError('You need to install `python-lxml` to run this script') 12 13 FORMATS_FILE_NAME = 'formats.py' 14 FORMATS_FILE_HEADER = '''# -*- encoding: utf-8 -*- 15 # This file is distributed under the same license as the Django package. 16 # 17 18 ''' 19 20 def quote(nodes, name, locale, previous): 21 if len(nodes): 22 return "'%s'" % unicode(nodes[0].text).replace("'", "\\'") 23 else: 24 return None 25 26 def convert_time(nodes, name, locale, previous): 27 SPECIAL_CHARS = ('a', 'A', 'b', 'B', 'd', 'D', 'f', 'F', 'g', 'G', 'h', 28 'H', 'i', 'I', 'j', 'l', 'L', 'm', 'M', 'n', 'N', 'O', 'P', 'r', 29 's', 'S', 't', 'T', 'U', 'w', 'W', 'y', 'Y', 'z', 'Z') 30 FORMAT_STR_MAP = ( # not using a dict, because we have to apply formats in order 31 ('dd', 'd'), 32 ('d', 'j'), 33 ('MMMM', 'F'), 34 ('MMM', 'M'), 35 ('MM', 'm'), 36 ('M', 'n'), 37 ('yyyy', 'Y'), 38 ('yy', 'y'), 39 ('y', 'Y'), 40 ('hh', 'h'), 41 ('h', 'g'), 42 ('HH', 'H'), 43 ('H', 'G'), 44 ('mm', 'i'), 45 ('ss', 's'), 46 ('a', 'A'), 47 ('LLLL', 'F'), 48 ) 49 if len(nodes): 50 original = nodes[0].text 51 result = '' 52 for cnt, segment in enumerate(original.split("'")): 53 if cnt % 2: 54 for char in SPECIAL_CHARS: 55 segment = segment.replace(char, '\\%s' % char) 56 result += segment 57 else: 58 while segment: 59 found = False 60 for src, dst in FORMAT_STR_MAP: 61 if segment[0:len(src)] == src: 62 result += dst 63 segment = segment[len(src):] 64 found = True 65 break 66 if not found: 67 result += segment[0] 68 segment = segment[1:] 69 70 return "'%s'" % result 71 else: 72 return None 73 74 def datetime(nodes, name, locale, previous): 75 result = None 76 if len(nodes) and 'DATE_FORMAT' in previous and 'TIME_FORMAT' in previous: 77 result = nodes[0].text 78 result = result.replace('{0}', previous['TIME_FORMAT'][1:-1]) 79 if name == 'SHORT_DATETIME_FORMAT' and 'SHORT_DATE_FORMAT' in previous: 80 result = result.replace('{1}', previous['SHORT_DATE_FORMAT'][1:-1]) 81 else: 82 result = result.replace('{1}', previous['DATE_FORMAT'][1:-1]) 83 if result: 84 return "'%s'" % result 85 else: 86 return None 87 88 FORMATS_MAP = [ 89 { 90 'name': 'DATE_FORMAT', 91 'file': os.path.join('common', 'main', '%(locale)s.xml'), 92 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateFormats/dateFormatLength[@type='long']/dateFormat/pattern", 93 'conversion': convert_time, 94 }, 95 { 96 'name': 'TIME_FORMAT', 97 'file': os.path.join('common', 'main', '%(locale)s.xml'), 98 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/timeFormats/timeFormatLength[@type='medium']/timeFormat/pattern", 99 'conversion': convert_time, 100 }, 101 { 102 'name': 'DATETIME_FORMAT', 103 'file': os.path.join('common', 'main', '%(locale)s.xml'), 104 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/dateTimeFormatLength[@type='long']/dateTimeFormat/pattern", 105 'conversion': datetime, 106 }, 107 { 108 'name': 'YEAR_MONTH_FORMAT', 109 'file': os.path.join('common', 'main', '%(locale)s.xml'), 110 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[@id='yMMMM']", 111 'conversion': convert_time, 112 }, 113 { 114 'name': 'MONTH_DAY_FORMAT', 115 'file': os.path.join('common', 'main', '%(locale)s.xml'), 116 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[@id='MMMMd']", 117 'conversion': convert_time, 118 }, 119 { 120 'name': 'SHORT_DATE_FORMAT', 121 'file': os.path.join('common', 'main', '%(locale)s.xml'), 122 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateFormats/dateFormatLength[@type='medium']/dateFormat/pattern", 123 'conversion': convert_time, 124 }, 125 { 126 'name': 'SHORT_DATETIME_FORMAT', 127 'file': os.path.join('common', 'main', '%(locale)s.xml'), 128 'pattern': "/ldml/dates/calendars/calendar[@type='gregorian']/dateTimeFormats/dateTimeFormatLength[@type='short']/dateTimeFormat/pattern", 129 'conversion': datetime, 130 }, 131 {'name': 'FIRST_DAY_OF_WEEK'}, 132 {'name': 'DATE_INPUT_FORMATS'}, 133 {'name': 'TIME_INPUT_FORMATS'}, 134 {'name': 'DATETIME_INPUT_FORMATS'}, 135 { 136 'name': 'DECIMAL_SEPARATOR', 137 'file': os.path.join('common', 'main', '%(locale)s.xml'), 138 'pattern': "/ldml/numbers/symbols/decimal", 139 'conversion': quote, 140 }, 141 { 142 'name': 'THOUSAND_SEPARATOR', 143 'file': os.path.join('common', 'main', '%(locale)s.xml'), 144 'pattern': "/ldml/numbers/symbols/group", 145 'conversion': quote, 146 }, 147 {'name': 'NUMBER_GROUPING'}, 148 ] 149 """ 150 """ 151 152 def get_locales(django_locale_dir, locale=None): 153 if locale: 154 yield locale 155 else: 156 locale_re = re.compile('[a-z]{2}(_[A-Z]{2})?') 157 for locale in os.listdir(django_locale_dir): 158 if locale_re.match(locale): 159 yield locale 160 161 def import_cldr(cldr_dir, locale=None, overwrite=False): 162 """ 163 For every locale defined in Django, get from the CLDR locale file all 164 settings defined in output_structure, and write the result to the 165 locale directories on Django. 166 """ 167 if not os.path.isdir(cldr_dir): 168 raise Exception, "Specified CLDR directory '%s' does not exist" % cldr_dir 169 170 import django 171 django_locale_dir = os.path.join(os.path.dirname(django.__file__), 'conf', 'locale') 172 173 for locale in get_locales(django_locale_dir, locale): 174 output_filename = os.path.join(django_locale_dir, locale, FORMATS_FILE_NAME) 175 if os.path.isfile(output_filename) and not overwrite: 176 print "'%s' locale already exists. Skipping" % locale 177 else: 178 result = {} 179 output_file = open(output_filename, 'w') 180 output_file.write(FORMATS_FILE_HEADER) 181 for format in FORMATS_MAP: 182 if 'file' in format: 183 cldr_file = os.path.join(cldr_dir, format['file'] % dict(locale=locale)) 184 tree = etree.parse(cldr_file) # TODO: error control 185 try: 186 original_value = tree.xpath(format['pattern']) 187 except IndexError: 188 output_file.write('# %s = \n' % (format['name'])) 189 else: 190 value = format['conversion'](original_value, format['name'], locale, result) 191 if value: 192 output_file.write('%s = %s\n' % (format['name'], value.encode('utf8'))) 193 result[format['name']] = value 194 else: 195 output_file.write('# %s = \n' % (format['name'])) 196 else: 197 output_file.write('# %s = \n' % (format['name'])) 198 output_file.close() 199 200 init_filename = os.path.join(django_locale_dir, locale, '__init__.py') 201 open(init_filename, 'a').close() 202 203 class Command(LabelCommand): 204 option_list = LabelCommand.option_list + ( 205 make_option('--locale', '-l', dest='locale', 206 help='The locale to process. Default is to process all.'), 207 ) + ( 208 make_option('--overwite', '-o', action='store_true', dest='overwrite', 209 help='Wheter to overwrite format definitions of locales that already have one.'), 210 ) 211 help = 'Creates format definition files for locales, importing data from the CLDR.' 212 args = '[cldrpath]' 213 label = 'CLDR path' 214 requires_model_validation = False 215 can_import_settings = False 216 217 def handle_label(self, cldrpath, **options): 218 locale = options.get('locale') 219 overwrite = options.get('overwrite') 220 import_cldr(cldrpath, locale, overwrite) 221 -
django/forms/extras/widgets.py
diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py index e36b8a1..04ad24d 100644
a b import re 8 8 from django.forms.widgets import Widget, Select 9 9 from django.utils.dates import MONTHS 10 10 from django.utils.safestring import mark_safe 11 from django.utils.formats import getformat 12 from django.conf import settings 11 13 12 14 __all__ = ('SelectDateWidget',) 13 15 … … class SelectDateWidget(Widget): 45 47 if match: 46 48 year_val, month_val, day_val = [int(v) for v in match.groups()] 47 49 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) 79 56 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) 80 71 return mark_safe(u'\n'.join(output)) 81 72 82 73 def id_for_label(self, id_): … … class SelectDateWidget(Widget): 90 81 if y == m == d == "0": 91 82 return None 92 83 if y and m and d: 93 return '%s-%s-%s' % (y, m, d) 84 if settings.USE_FORMAT_I18N: 85 input_format = getformat('DATE_INPUT_FORMATS')[0] 86 try: 87 date_value = datetime.date(int(y), int(m), int(d)) 88 except ValueError: 89 pass 90 else: 91 return date_value.strftime(input_format) 92 else: 93 return '%s-%s-%s' % (y, m, d) 94 94 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..6009096 100644
a b import django.core.exceptions 17 17 import django.utils.copycompat as copy 18 18 from django.utils.translation import ugettext_lazy as _ 19 19 from django.utils.encoding import smart_unicode, smart_str 20 from django.utils.formats import getformat 20 21 21 22 from util import ErrorList, ValidationError 22 23 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget 23 24 24 25 __all__ = ( 25 26 'Field', 'CharField', 'IntegerField', 26 'DEFAULT_DATE_INPUT_FORMATS', 'DateField', 27 'DEFAULT_TIME_INPUT_FORMATS', 'TimeField', 28 'DEFAULT_DATETIME_INPUT_FORMATS', 'DateTimeField', 'TimeField', 27 'DateField', 'TimeField', 'DateTimeField', 'TimeField', 29 28 'RegexField', 'EmailField', 'FileField', 'ImageField', 'URLField', 30 29 'BooleanField', 'NullBooleanField', 'ChoiceField', 'MultipleChoiceField', 31 30 'ComboField', 'MultiValueField', 'FloatField', 'DecimalField', … … class FloatField(Field): 200 199 if not self.required and value in EMPTY_VALUES: 201 200 return None 202 201 try: 203 value = float(value) 202 # We always accept dot as decimal separator 203 if isinstance(value, str) or isinstance(value, unicode): 204 value = float(value.replace(getformat('DECIMAL_SEPARATOR'), '.')) 204 205 except (ValueError, TypeError): 205 206 raise ValidationError(self.error_messages['invalid']) 206 207 if self.max_value is not None and value > self.max_value: … … class DecimalField(Field): 236 237 return None 237 238 value = smart_str(value).strip() 238 239 try: 239 value = Decimal(value) 240 # We always accept dot as decimal separator 241 if isinstance(value, str) or isinstance(value, unicode): 242 value = Decimal(value.replace(getformat('DECIMAL_SEPARATOR'), '.')) 240 243 except DecimalException: 241 244 raise ValidationError(self.error_messages['invalid']) 242 245 … … class DecimalField(Field): 264 267 raise ValidationError(self.error_messages['max_whole_digits'] % (self.max_digits - self.decimal_places)) 265 268 return value 266 269 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 275 270 class DateField(Field): 276 271 widget = DateInput 277 272 default_error_messages = { … … class DateField(Field): 280 275 281 276 def __init__(self, input_formats=None, *args, **kwargs): 282 277 super(DateField, self).__init__(*args, **kwargs) 283 self.input_formats = input_formats or DEFAULT_DATE_INPUT_FORMATS278 self.input_formats = input_formats 284 279 285 280 def clean(self, value): 286 281 """ … … class DateField(Field): 294 289 return value.date() 295 290 if isinstance(value, datetime.date): 296 291 return value 297 for format in self.input_formats :292 for format in self.input_formats or getformat('DATE_INPUT_FORMATS'): 298 293 try: 299 294 return datetime.date(*time.strptime(value, format)[:3]) 300 295 except ValueError: 301 296 continue 302 297 raise ValidationError(self.error_messages['invalid']) 303 298 304 DEFAULT_TIME_INPUT_FORMATS = (305 '%H:%M:%S', # '14:30:59'306 '%H:%M', # '14:30'307 )308 309 299 class TimeField(Field): 310 300 widget = TimeInput 311 301 default_error_messages = { … … class TimeField(Field): 314 304 315 305 def __init__(self, input_formats=None, *args, **kwargs): 316 306 super(TimeField, self).__init__(*args, **kwargs) 317 self.input_formats = input_formats or DEFAULT_TIME_INPUT_FORMATS307 self.input_formats = input_formats 318 308 319 309 def clean(self, value): 320 310 """ … … class TimeField(Field): 326 316 return None 327 317 if isinstance(value, datetime.time): 328 318 return value 329 for format in self.input_formats :319 for format in self.input_formats or getformat('TIME_INPUT_FORMATS'): 330 320 try: 331 321 return datetime.time(*time.strptime(value, format)[3:6]) 332 322 except ValueError: 333 323 continue 334 324 raise ValidationError(self.error_messages['invalid']) 335 325 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 348 326 class DateTimeField(Field): 349 327 widget = DateTimeInput 350 328 default_error_messages = { … … class DateTimeField(Field): 353 331 354 332 def __init__(self, input_formats=None, *args, **kwargs): 355 333 super(DateTimeField, self).__init__(*args, **kwargs) 356 self.input_formats = input_formats or DEFAULT_DATETIME_INPUT_FORMATS334 self.input_formats = input_formats 357 335 358 336 def clean(self, value): 359 337 """ … … class DateTimeField(Field): 373 351 if len(value) != 2: 374 352 raise ValidationError(self.error_messages['invalid']) 375 353 value = '%s %s' % tuple(value) 376 for format in self.input_formats :354 for format in self.input_formats or getformat('DATETIME_INPUT_FORMATS'): 377 355 try: 378 356 return datetime.datetime(*time.strptime(value, format)[:6]) 379 357 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 10 10 from django.utils.translation import ugettext 11 11 from django.utils.encoding import StrAndUnicode, force_unicode 12 12 from django.utils.safestring import mark_safe 13 from django.utils.formats import localize 13 14 from django.utils import datetime_safe 14 15 from datetime import time 15 16 from util import flatatt … … class Input(Widget): 208 209 final_attrs = self.build_attrs(attrs, type=self.input_type, name=name) 209 210 if value != '': 210 211 # 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)) 212 213 return mark_safe(u'<input%s />' % flatatt(final_attrs)) 213 214 214 215 class 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 60 60 from django.utils.encoding import smart_unicode, force_unicode, smart_str 61 61 from django.utils.translation import ugettext as _ 62 62 from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping 63 from django.utils.formats import localize 63 64 from django.utils.html import escape 64 65 65 66 __all__ = ('Template', 'Context', 'RequestContext', 'compile_string') … … def _render_value_in_context(value, context): 815 816 means escaping, if required, and conversion to a unicode object. If value 816 817 is a string, it is expected to have already been translated. 817 818 """ 819 value = localize(value) 818 820 value = force_unicode(value) 819 821 if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData): 820 822 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 2 2 from django.utils.encoding import force_unicode 3 3 from django.utils.html import escape 4 4 from django.utils.safestring import SafeData, EscapeData 5 from django.utils.formats import localize 5 6 6 7 class DebugLexer(Lexer): 7 8 def __init__(self, template_string, origin): … … class DebugNodeList(NodeList): 84 85 class DebugVariableNode(VariableNode): 85 86 def render(self, context): 86 87 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) 88 91 except TemplateSyntaxError, e: 89 92 if not hasattr(e, 'source'): 90 93 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 18 18 from django.utils.translation import ugettext, ungettext 19 19 from django.utils.encoding import force_unicode, iri_to_uri 20 20 from django.utils.safestring import mark_safe, SafeData 21 from django.utils.formats import date_format, number_format 21 22 22 23 register = Library() 23 24 … … def floatformat(text, arg=-1): 166 167 return input_val 167 168 168 169 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)) 170 171 171 172 if p == 0: 172 173 exp = Decimal(1) 173 174 else: 174 175 exp = Decimal('1.0') / (Decimal(10) ** abs(p)) 175 176 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))) 177 178 except InvalidOperation: 178 179 return input_val 179 180 floatformat.is_safe = True … … def date(value, arg=None): 685 686 if arg is None: 686 687 arg = settings.DATE_FORMAT 687 688 try: 688 return format(value, arg)689 return date_format(value, arg) 689 690 except AttributeError: 690 return '' 691 try: 692 return format(value, arg) 693 except AttributeError: 694 return '' 691 695 date.is_safe = False 692 696 693 697 def time(value, arg=None): … … def time(value, arg=None): 698 702 if arg is None: 699 703 arg = settings.TIME_FORMAT 700 704 try: 701 return time_format(value, arg)705 return date_format(value, arg) 702 706 except AttributeError: 703 return '' 707 try: 708 return time_format(value, arg) 709 except AttributeError: 710 return '' 704 711 time.is_safe = False 705 712 706 713 def 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..51737b2
- + 1 import decimal 2 import datetime 3 4 from django.conf import settings 5 from django.utils.translation import get_language, to_locale, check_for_language 6 from django.utils.importlib import import_module 7 from django.utils import dateformat 8 from django.utils import numberformat 9 10 def 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 35 def 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_I18N and settings.USE_FORMAT_I18N: 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 49 def 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 56 def 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 68 def localize(value, is_input=False): 69 """ 70 Checks value, and if it has a localizable type (date, 71 number...) it returns the value as a string using 72 current locale format 73 """ 74 if settings.USE_I18N and settings.USE_FORMAT_I18N: 75 if isinstance(value, decimal.Decimal): 76 return number_format(value) 77 elif isinstance(value, float): 78 return number_format(value) 79 elif isinstance(value, int): 80 return number_format(value) 81 elif isinstance(value, datetime.datetime): 82 if not is_input: 83 return date_format(value, 'DATETIME_FORMAT') 84 else: 85 return value.strftime(getformat('DATETIME_INPUT_FORMATS')[0]) 86 elif isinstance(value, datetime.date): 87 if not is_input: 88 return date_format(value) 89 else: 90 return value.strftime(getformat('DATE_INPUT_FORMATS')[0]) 91 elif isinstance(value, datetime.time): 92 if not is_input: 93 return date_format(value, 'TIME_FORMAT') 94 else: 95 return value.strftime(getformat('TIME_INPUT_FORMATS')[0]) 96 return value 97 -
new file django/utils/numberformat.py
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py new file mode 100644 index 0000000..78ecb2f
- + 1 from django.conf import settings 2 3 def 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 2 2 # that don't actually do anything. This is purely for performance, so that 3 3 # settings.USE_I18N = False can use this module rather than trans_real.py. 4 4 5 import warnings 5 6 from django.conf import settings 6 7 from django.utils.encoding import force_unicode 7 8 from django.utils.safestring import mark_safe, SafeData … … activate = lambda x: None 18 19 deactivate = deactivate_all = lambda: None 19 20 get_language = lambda: settings.LANGUAGE_CODE 20 21 get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI 21 get_date_formats = lambda: (settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT)22 get_partial_date_formats = lambda: (settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT)23 22 check_for_language = lambda x: True 24 23 24 # date formats shouldn't be used using gettext anymore. This 25 # is kept for backward compatibility 25 26 TECHNICAL_ID_MAP = { 26 27 "DATE_WITH_TIME_FULL": settings.DATETIME_FORMAT, 27 28 "DATE_FORMAT": settings.DATE_FORMAT, … … def to_locale(language): 51 52 52 53 def get_language_from_request(request): 53 54 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. 58 def 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 66 def 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 4 4 import os 5 5 import re 6 6 import sys 7 import warnings 7 8 import gettext as gettext_module 8 9 from cStringIO import StringIO 9 10 … … def do_translate(message, translation_function): 266 267 translation object to use. If no current translation is activated, the 267 268 message will be run through the default translation object. 268 269 """ 270 eol_message = message.replace('\r\n', '\n').replace('\r', '\n') 269 271 global _default, _active 270 272 t = _active.get(currentThread(), None) 271 273 if t is not None: 272 result = getattr(t, translation_function)( message)274 result = getattr(t, translation_function)(eol_message) 273 275 else: 274 276 if _default is None: 275 277 from django.conf import settings 276 278 _default = translation(settings.LANGUAGE_CODE) 277 result = getattr(_default, translation_function)( message)279 result = getattr(_default, translation_function)(eol_message) 278 280 if isinstance(message, SafeData): 279 281 return mark_safe(result) 280 282 return result … … def get_language_from_request(request): 389 391 390 392 return settings.LANGUAGE_CODE 391 393 392 def get_date_formats():393 """394 Checks whether translation files provide a translation for some technical395 message ID to store date and time formats. If it doesn't contain one, the396 formats provided in the settings will be used.397 """398 from django.conf import settings399 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_FORMAT404 if datetime_format == 'DATETIME_FORMAT':405 datetime_format = settings.DATETIME_FORMAT406 if time_format == 'TIME_FORMAT':407 time_format = settings.TIME_FORMAT408 return date_format, datetime_format, time_format409 410 def get_partial_date_formats():411 """412 Checks whether translation files provide a translation for some technical413 message ID to store partial date formats. If it doesn't contain one, the414 formats provided in the settings will be used.415 """416 from django.conf import settings417 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_FORMAT421 if month_day_format == 'MONTH_DAY_FORMAT':422 month_day_format = settings.MONTH_DAY_FORMAT423 return year_month_format, month_day_format424 425 394 dot_re = re.compile(r'\S') 426 395 def blankout(src, char): 427 396 """ … … def parse_accept_lang_header(lang_string): 537 506 result.append((lang, priority)) 538 507 result.sort(lambda x, y: -cmp(x[1], y[1])) 539 508 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 515 def 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 538 def 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 1 import os 2 import gettext as gettext_module 3 1 4 from django import http 2 5 from django.conf import settings 3 6 from django.utils import importlib 4 7 from django.utils.translation import check_for_language, activate, to_locale, get_language 5 8 from django.utils.text import javascript_quote 6 import os 7 import gettext as gettext_module 9 from django.utils.formats import get_format_modules 8 10 9 11 def set_language(request): 10 12 """ … … def set_language(request): 32 34 response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code) 33 35 return response 34 36 37 def 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 35 55 NullSource = """ 36 56 /* gettext identity library */ 37 57 … … def javascript_catalog(request, domain='djangojs', packages=None): 185 205 else: 186 206 raise TypeError, k 187 207 csrc.sort() 188 for k, v in pdict.items():208 for k, v in pdict.items(): 189 209 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)))) 190 212 src.extend(csrc) 191 213 src.append(LibFoot) 192 214 src.append(InterPolate) 193 215 src = ''.join(src) 194 216 return http.HttpResponse(src, 'text/javascript') 217 -
docs/ref/settings.txt
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index 8ff1509..1b57adf 100644
a b DATE_FORMAT 288 288 289 289 Default: ``'N j, Y'`` (e.g. ``Feb. 4, 2003``) 290 290 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>`. 291 The default formatting to use for date fields in any part of the system. 292 Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will 293 be applied. See :ttag:`allowed date format strings <now>`. 294 295 See also ``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``SHORT_DATE_FORMAT``. 296 297 .. setting:: DATE_INPUT_FORMATS 294 298 295 See also ``DATETIME_FORMAT``, ``TIME_FORMAT``, ``YEAR_MONTH_FORMAT`` 296 and ``MONTH_DAY_FORMAT``. 299 DATE_INPUT_FORMATS 300 ------------------ 301 302 Default:: 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 308 A tuple of formats that will be accepted when inputting data on a date 309 field. Formats will be tried in order, using the first valid. 310 Note that these format strings are specified in Python's datetime_ module 311 syntax, that is different from the one used by Django for formatting dates 312 to be displayed. 313 314 See also ``DATETIME_INPUT_FORMATS`` and ``TIME_INPUT_FORMATS``. 315 316 .. _datetime: http://docs.python.org/library/datetime.html#strftime-behavior 297 317 298 318 .. setting:: DATETIME_FORMAT 299 319 … … DATETIME_FORMAT 302 322 303 323 Default: ``'N j, Y, P'`` (e.g. ``Feb. 4, 2003, 4 p.m.``) 304 324 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>`. 325 The default formatting to use for datetime fields in any part of the system. 326 Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will 327 be applied. See :ttag:`allowed date format strings <now>`. 328 329 See also ``DATE_FORMAT``, ``TIME_FORMAT`` and ``SHORT_DATETIME_FORMAT``. 308 330 309 See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``, 310 ``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``. 331 .. setting:: DATETIME_INPUT_FORMATS 332 333 DATETIME_INPUT_FORMATS 334 ---------------------- 335 336 Default:: 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 342 A tuple of formats that will be accepted when inputting data on a datetime 343 field. Formats will be tried in order, using the first valid. 344 Note that these format strings are specified in Python's datetime_ module 345 syntax, that is different from the one used by Django for formatting dates 346 to be displayed. 347 348 See also ``DATE_INPUT_FORMATS`` and ``TIME_INPUT_FORMATS``. 349 350 .. _datetime: http://docs.python.org/library/datetime.html#strftime-behavior 311 351 312 352 .. setting:: DEBUG 313 353 … … will be suppressed, and exceptions will propagate upwards. This can 347 387 be useful for some test setups, and should never be used on a live 348 388 site. 349 389 390 .. setting:: DECIMAL_SEPARATOR 391 392 DECIMAL_SEPARATOR 393 ----------------- 394 395 Default: ``'.'`` (Dot) 396 397 Default decimal separator used when formatting decimal numbers. 350 398 351 399 .. setting:: DEFAULT_CHARSET 352 400 … … system's standard umask. 596 644 597 645 .. _documentation for os.chmod: http://docs.python.org/lib/os-file-dir.html 598 646 647 .. setting:: FIRST_DAY_OF_WEEK 648 649 FIRST_DAY_OF_WEEK 650 ----------------- 651 652 Default: ``0`` (Sunday) 653 654 Number representing the first day of the week. This is specially useful 655 when displaying a calendar. This value is only used when not using 656 format internationalization, or when a format cannot be found for the 657 current locale. 658 659 The value must be an integer from 0 to 6, where 0 means Sunday, 1 means 660 Monday and so on. 661 599 662 .. setting:: FIXTURE_DIRS 600 663 601 664 FIXTURE_DIRS … … environment variable in any HTTP request. This setting can be used to override 617 680 the server-provided value of ``SCRIPT_NAME``, which may be a rewritten version 618 681 of the preferred value or not supplied at all. 619 682 683 .. setting:: FORMAT_MODULE_PATH 684 685 FORMAT_MODULE_PATH 686 ------------------ 687 688 Default: ``None`` 689 690 A full Python path to a Python package that contains format definitions for 691 project locales. If not ``None``, Django will check for a ``formats.py`` 692 file, under the directory named as the current locale, and will use the 693 formats defined on this file. 694 695 For example, if ``FORMAT_MODULE_PATH`` is set to ``mysite.formats``, and 696 current language is ``en`` (English), Django will expect a directory tree 697 like:: 698 699 mysite/ 700 formats/ 701 __init__.py 702 en/ 703 __init__.py 704 formats.py 705 706 Available 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 620 711 .. setting:: IGNORABLE_404_ENDS 621 712 622 713 IGNORABLE_404_ENDS … … locales have different formats. For example, U.S. English would say 886 977 See :ttag:`allowed date format strings <now>`. See also ``DATE_FORMAT``, 887 978 ``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``YEAR_MONTH_FORMAT``. 888 979 980 .. setting:: NUMBER_GROUPING 981 982 NUMBER_GROUPING 983 ---------------- 984 985 Default: ``0`` 986 987 Number of digits grouped together on the integer part of a number. Common use 988 is to display a thousand separator. If this setting is ``0``, then, no grouping 989 will be applied to the number. If this setting is greater than ``0`` then the 990 setting ``THOUSAND_SEPARATOR`` will be used as the separator between those 991 groups. 992 993 See also ``THOUSAND_SEPARATOR`` 994 889 995 .. setting:: PREPEND_WWW 890 996 891 997 PREPEND_WWW … … Default: ``False`` 1077 1183 Whether to save the session data on every request. See 1078 1184 :ref:`topics-http-sessions`. 1079 1185 1186 .. setting:: SHORT_DATE_FORMAT 1187 1188 SHORT_DATE_FORMAT 1189 ----------------- 1190 1191 Default: ``m/d/Y`` (e.g. ``12/31/2003``) 1192 1193 An available formatting that can be used for date fields on templates. 1194 Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will 1195 be applied. See :ttag:`allowed date format strings <now>`. 1196 1197 See also ``DATE_FORMAT`` and ``SHORT_DATETIME_FORMAT``. 1198 1199 .. setting:: SHORT_DATETIME_FORMAT 1200 1201 SHORT_DATETIME_FORMAT 1202 --------------------- 1203 1204 Default: ``m/d/Y P`` (e.g. ``12/31/2003 4 p.m.``) 1205 1206 An available formatting that can be used for datetime fields on templates. 1207 Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will 1208 be applied. See :ttag:`allowed date format strings <now>`. 1209 1210 See also ``DATE_FORMAT`` and ``SHORT_DATETIME_FORMAT``. 1211 1080 1212 .. setting:: SITE_ID 1081 1213 1082 1214 SITE_ID … … The name of the method to use for starting the test suite. See 1231 1363 1232 1364 .. _Testing Django Applications: ../testing/ 1233 1365 1366 .. setting:: THOUSAND_SEPARATOR 1367 1368 THOUSAND_SEPARATOR 1369 ------------------ 1370 1371 Default ``,`` (Comma) 1372 1373 Default thousand separator used when formatting numbers. This setting is 1374 used only when ``NUMBER_GROUPPING`` is set. 1375 1376 See also ``NUMBER_GROUPPING``, ``DECIMAL_SEPARATOR`` 1377 1234 1378 .. setting:: TIME_FORMAT 1235 1379 1236 1380 TIME_FORMAT … … TIME_FORMAT 1238 1382 1239 1383 Default: ``'P'`` (e.g. ``4 p.m.``) 1240 1384 1241 The default formatting to use for time fields on Django admin change-list1242 pages -- and, possibly, by other parts of the system. See 1243 :ttag:`allowed date format strings <now>`.1385 The default formatting to use for time fields in any part of the system. 1386 Note that if ``USE_FORMAT_I18N`` is set to ``True``, then locale format will 1387 be applied. See :ttag:`allowed date format strings <now>`. 1244 1388 1245 See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``, 1246 ``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``. 1389 See also ``DATE_FORMAT`` and ``DATETIME_FORMAT``. 1390 1391 .. setting:: TIME_INPUT_FORMATS 1392 1393 TIME_INPUT_FORMATS 1394 ------------------ 1395 1396 Default: ``('%H:%M:%S', '%H:%M')`` 1397 1398 A tuple of formats that will be accepted when inputting data on a time 1399 field. Formats will be tried in order, using the first valid. 1400 Note that these format strings are specified in Python's datetime_ module 1401 syntax, that is different from the one used by Django for formatting dates 1402 to be displayed. 1403 1404 See also ``DATE_INPUT_FORMATS`` and ``DATETIME_INPUT_FORMATS``. 1405 1406 .. _datetime: http://docs.python.org/library/datetime.html#strftime-behavior 1247 1407 1248 1408 .. setting:: TIME_ZONE 1249 1409 … … A boolean that specifies whether to output the "Etag" header. This saves 1298 1458 bandwidth but slows down performance. This is only used if ``CommonMiddleware`` 1299 1459 is installed (see :ref:`topics-http-middleware`). 1300 1460 1461 .. setting:: USE_FORMAT_I18N 1462 1463 USE_FORMAT_I18N 1464 --------------- 1465 1466 Default ``False`` 1467 1468 A boolean that specifies if data will be localized by default or not. If this is 1469 set to ``True``, Django will display numbers and dates using the format of the 1470 current locale. It is required to set ``USE_I18N`` to ``True`` to allow data 1471 format localization. 1472 1473 See also ``USE_I18N`` 1474 1301 1475 .. setting:: USE_I18N 1302 1476 1303 1477 USE_I18N … … enabled. This provides an easy way to turn it off, for performance. If this is 1310 1484 set to ``False``, Django will make some optimizations so as not to load the 1311 1485 internationalization machinery. 1312 1486 1487 See also ``USE_FORMAT_I18N`` 1488 1489 .. setting:: USE_THOUSAND_SEPARATOR 1490 1491 USE_THOUSAND_SEPARATOR 1492 ---------------------- 1493 1494 Default ``False`` 1495 1496 A boolean that specifies wheter to display numbers using a thousand separator. 1497 If this is set to ``True``, Django will use values from ``THOUSAND_SEPARATOR`` 1498 and ``NUMBER_GROUPING`` from current locale, to format the number. 1499 ``USE_FORMAT_I18N`` must be set to ``True``, in order to format numbers. 1500 1501 See also ``THOUSAND_SEPARATOR`` and ``NUMBER_GROUPING``. 1502 1313 1503 .. setting:: YEAR_MONTH_FORMAT 1314 1504 1315 1505 YEAR_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 1047 1047 date 1048 1048 ~~~~ 1049 1049 1050 Formats a date according to the given format (same as the `now`_ tag). 1050 Formats a date according to the given format. 1051 1052 Given 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. 1051 1055 1052 1056 For example:: 1053 1057 … … When used without a format string:: 1062 1066 {{ value|date }} 1063 1067 1064 1068 ...the formatting string defined in the :setting:`DATE_FORMAT` setting will be 1065 used .1069 used, without applying any localization. 1066 1070 1067 1071 .. templatefilter:: default 1068 1072 … … output will be ``"Joel is a slug"``. 1610 1614 time 1611 1615 ~~~~ 1612 1616 1613 Formats a time according to the given format (same as the `now`_ tag). 1617 Formats a time according to the given format. 1618 1619 Given format can be the predefined one ``TIME_FORMAT``, or a custom format, 1620 same as the `now`_ tag. Note that the predefined format is locale depending. 1621 1614 1622 The time filter will only accept parameters in the format string that relate 1615 1623 to the time of day, not the date (for obvious reasons). If you need to 1616 1624 format a date, use the `date`_ filter. … … When used without a format string:: 1627 1635 {{ value|time }} 1628 1636 1629 1637 ...the formatting string defined in the :setting:`TIME_FORMAT` setting will be 1630 used .1638 used, without aplying any localization. 1631 1639 1632 1640 .. templatefilter:: timesince 1633 1641 -
docs/topics/i18n.txt
diff --git a/docs/topics/i18n.txt b/docs/topics/i18n.txt index c5f4ab6..0fd2663 100644
a b 4 4 Internationalization 5 5 ==================== 6 6 7 Django has full support for internationalization of text in code and templates. 8 Here's how it works. 7 Django has full support for internationalization, including translation 8 capabilities of text in code and templates, and format localization for 9 dates and numbers. Here's how it works. 9 10 10 11 Overview 11 12 ======== 12 13 13 14 The goal of internationalization is to allow a single Web application to offer 14 its content and functionality in multiple languages .15 its content and functionality in multiple languages and locales. 15 16 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 t he end user's language, if a translation for this text is available in that20 language."17 For text translation, you, the Django developer, can accomplish this goal by 18 adding a minimal amount of hooks to your Python code and templates. These hooks 19 are called **translation strings**. They tell Django: "This text should be 20 translated into the end user's language, if a translation for this text is 21 available in that language." 21 22 22 23 Django takes care of using these hooks to translate Web apps, on the fly, 23 24 according to users' language preferences. … … Essentially, Django does two things: 29 30 * It uses these hooks to translate Web apps for particular users according 30 31 to their language preferences. 31 32 33 For format localization, it's just necessary to set 34 :setting:`USE_FORMAT_I18N = True <USE_FORMAT_I18N>` in your settings file. If 35 :settings:`USE_FORMAT_I18N` is set to ``True``, then Django will display 36 numbers and dates in the format of the current locale. That includes field 37 representation on templates, and allowed input formats on the admin. 38 32 39 If you don't need internationalization in your app 33 40 ================================================== 34 41 … … have been found to not support this command. Do not attempt to use Django 1074 1081 translation utilities with a ``gettext`` package if the command ``xgettext 1075 1082 --version`` entered at a Windows command prompt causes a popup window saying 1076 1083 "xgettext.exe has generated errors and will be closed by Windows". 1084 1085 Format localization 1086 =================== 1087 1088 Django's formatting system is disabled by default. To enable it, it's necessay 1089 to set :setting:`USE_FORMAT_I18N = True <USE_FORMAT_I18N>` in your settings 1090 file. Note that :setting:`USE_FORMAT_I18N` requires `USE_I18N` to be ``True``. 1091 1092 When using Django's formatting system, dates and numbers on templates will be 1093 displayed using the format specified for the current locale. That means, two 1094 users accessing the same content, but in different language, will see date and 1095 number fields formatted in different ways, depending on the format for their 1096 current locale. 1097 1098 Django will also use localized formats when parsing data in forms. That means 1099 Django uses different formats for different locales when guessing the format 1100 used by the user when inputting data on forms. Note that Django uses different 1101 formats for displaying data, and for parsing it. 1102 1103 Creating custom format files 1104 ---------------------------- 1105 1106 Django provides format definitions for many locales, but sometimes you could 1107 want to create your own ones, because a format files doesn't exist for your 1108 locale, or because you want to overwrite some of the values. 1109 1110 To use custom formats, first thing to do, is to specify the path where you'll 1111 place format files. To do that, just set :setting:`FORMAT_MODULE_PATH` setting 1112 to the the path (in the format ``'foo.bar.baz``) where format files will 1113 exists. 1114 1115 Files are not placed directly in this directory, but in a directory named as 1116 the locale. File must be named ``formats.py``. 1117 1118 For 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 1127 where :file:`formats.py` contains custom format definitions. For example:: 1128 1129 THOUSAND_SEPARATOR = ' ' 1130 1131 to use a space as thousand separator, instead of the default for English, 1132 comma. 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 sys2 3 tests = """4 >>> from django.utils.translation.trans_real import parse_accept_lang_header5 >>> p = parse_accept_lang_header6 7 #8 # Testing HTTP header parsing. First, we test that we can parse the values9 # 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_request69 >>> g = get_language_from_request70 >>> from django.http import HttpRequest71 >>> r = HttpRequest72 >>> r.COOKIES = {}73 74 These tests assumes the es, es_AR, pt and pt_BR translations exit in the Django75 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 bogus91 # locales, so we omit this test for that anything below 2.4. It's relatively92 # harmless in any cases (GIGO). This also means this won't be executed on93 # 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 variation98 of the Spanish language, a safe assumption. When the user sets it99 as the preferred language, the main 'es' translation should be selected100 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 by110 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..2ab4ce6 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 } 1 import sys 2 from django.test import TestCase, client 3 from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy 4 5 class TranslationTests(TestCase): 6 7 def test_lazy_objects(self): 8 """ 9 Format string interpolation should work with *_lazy objects. 10 """ 11 s = ugettext_lazy('Add %(name)s') 12 d = {'name': 'Ringo'} 13 self.assertEqual(u'Add Ringo', s % d) 14 activate('de') 15 self.assertEqual(u'Ringo hinzuf\xfcgen', s % d) 16 activate('pl') 17 self.assertEqual(u'Dodaj Ringo', s % d) 18 deactivate() 19 20 # It should be possible to compare *_lazy objects. 21 s1 = ugettext_lazy('Add %(name)s') 22 self.assertEqual(True, s == s1) 23 s2 = gettext_lazy('Add %(name)s') 24 s3 = gettext_lazy('Add %(name)s') 25 self.assertEqual(True, s2 == s3) 26 self.assertEqual(True, s == s2) 27 s4 = ugettext_lazy('Some other string') 28 self.assertEqual(False, s == s4) 29 30 def test_string_concat(self): 31 """ 32 unicode(string_concat(...)) should not raise a TypeError - #4796 33 """ 34 import django.utils.translation 35 self.assertEqual(django.utils.translation, reload(django.utils.translation)) 36 self.assertEqual(u'django', unicode(django.utils.translation.string_concat("dja", "ngo"))) 37 38 def test_safe_status(self): 39 """ 40 Translating a string requiring no auto-escaping shouldn't change the "safe" status. 41 """ 42 from django.utils.safestring import mark_safe, SafeString, SafeUnicode 43 s = mark_safe('Password') 44 self.assertEqual(SafeString, type(s)) 45 activate('de') 46 self.assertEqual(SafeUnicode, type(ugettext(s))) 47 deactivate() 48 self.assertEqual('aPassword', SafeString('a') + s) 49 self.assertEqual('Passworda', s + SafeString('a')) 50 self.assertEqual('Passworda', s + mark_safe('a')) 51 self.assertEqual('aPassword', mark_safe('a') + s) 52 self.assertEqual('as', mark_safe('a') + mark_safe('s')) 53 #self.assertEqual(Password, print s) 54 55 def test_maclines(self): 56 """ 57 Translations on files with mac or dos end of lines will be converted 58 to unix eof in .po catalogs, and they have to match when retrieved 59 """ 60 from django.utils.translation.trans_real import translation 61 ca_translation = translation('ca') 62 ca_translation._catalog[u'Mac\nEOF\n'] = u'Catalan Mac\nEOF\n' 63 ca_translation._catalog[u'Win\nEOF\n'] = u'Catalan Win\nEOF\n' 64 activate('ca') 65 self.assertEqual(u'Catalan Mac\nEOF\n', ugettext(u'Mac\rEOF\r')) 66 self.assertEqual(u'Catalan Win\nEOF\n', ugettext(u'Win\r\nEOF\r\n')) 67 deactivate() 68 69 def test_dates_and_numbers(self): 70 """ 71 Localization of dates and numbers 72 """ 73 import datetime 74 import decimal 75 from django.conf import settings 76 from django.utils.formats import getformat, date_format, number_format, localize 77 from django.utils.numberformat import format 78 from django import template, forms 79 from django.forms.extras import SelectDateWidget 80 81 old_use_i18n = settings.USE_I18N 82 old_use_format_i18n = settings.USE_FORMAT_I18N 83 old_use_thousand_separator = settings.USE_THOUSAND_SEPARATOR 84 85 n = decimal.Decimal('66666.666') 86 f = 99999.999 87 d = datetime.date(2009, 12, 31) 88 dt = datetime.datetime(2009, 12, 31, 20, 50) 89 ctxt = template.Context({'n': n, 'd': d, 'dt': dt, 'f': f}) 90 91 # Locale independent 92 93 class I18nForm(forms.Form): 94 decimal_field = forms.DecimalField() 95 float_field = forms.FloatField() 96 date_field = forms.DateField() 97 datetime_field = forms.DateTimeField() 98 time_field = forms.TimeField() 99 100 class SelectDateForm(forms.Form): 101 date_field = forms.DateField(widget=SelectDateWidget) 102 103 settings.USE_FORMAT_I18N = True 104 settings.USE_THOUSAND_SEPARATOR = False 105 self.assertEqual(u'66666.66', format(n, decimal_sep='.', decimal_pos=2, grouping=3, thousand_sep=',')) 106 self.assertEqual(u'66666A6', format(n, decimal_sep='A', decimal_pos=1, grouping=1, thousand_sep='B')) 107 108 settings.USE_THOUSAND_SEPARATOR = True 109 self.assertEqual(u'66,666.66', format(n, decimal_sep='.', decimal_pos=2, grouping=3, thousand_sep=',')) 110 self.assertEqual(u'6B6B6B6B6A6', format(n, decimal_sep='A', decimal_pos=1, grouping=1, thousand_sep='B')) 111 self.assertEqual(u'-66666.6', format(-66666.666, decimal_sep='.', decimal_pos=1)) 112 self.assertEqual(u'-66666.0', format(int('-66666'), decimal_sep='.', decimal_pos=1)) 113 114 # Catalan locale with format i18n disabled translations will be used, but not formats 115 116 settings.USE_FORMAT_I18N = False 117 activate('ca') 118 self.assertEqual('N j, Y', getformat('DATE_FORMAT')) 119 self.assertEqual(0, getformat('FIRST_DAY_OF_WEEK')) 120 self.assertEqual('.', getformat('DECIMAL_SEPARATOR')) 121 self.assertEqual(u'des. 31, 2009', date_format(d)) 122 self.assertEqual(u'desembre 2009', date_format(d, 'YEAR_MONTH_FORMAT')) 123 self.assertEqual(u'12/31/2009 8:50 p.m.', date_format(dt, 'SHORT_DATETIME_FORMAT')) 124 self.assertEqual('No localizable', localize('No localizable')) 125 self.assertEqual(decimal.Decimal('66666.666'), localize(n)) 126 self.assertEqual(99999.999, localize(f)) 127 self.assertEqual(datetime.date(2009, 12, 31), localize(d)) 128 self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), localize(dt)) 129 self.assertEqual(u'66666.666', template.Template('{{ n }}').render(ctxt)) 130 self.assertEqual(u'99999.999', template.Template('{{ f }}').render(ctxt)) 131 self.assertEqual(u'2009-12-31', template.Template('{{ d }}').render(ctxt)) 132 self.assertEqual(u'2009-12-31 20:50:00', template.Template('{{ dt }}').render(ctxt)) 133 self.assertEqual(u'66666.67', template.Template('{{ n|floatformat:2 }}').render(ctxt)) 134 self.assertEqual(u'100000.0', template.Template('{{ f|floatformat }}').render(ctxt)) 135 self.assertEqual(u'12/31/2009', template.Template('{{ d|date:"SHORT_DATE_FORMAT" }}').render(ctxt)) 136 self.assertEqual(u'12/31/2009 8:50 p.m.', template.Template('{{ dt|date:"SHORT_DATETIME_FORMAT" }}').render(ctxt)) 137 138 form = I18nForm({ 139 'decimal_field': u'66666,666', 140 'float_field': u'99999,999', 141 'date_field': u'31/12/2009', 142 'datetime_field': u'31/12/2009 20:50', 143 'time_field': u'20:50' 144 }) 145 self.assertEqual(False, form.is_valid()) 146 self.assertEqual([u'Introdu\xefu un n\xfamero.'], form.errors['float_field']) 147 self.assertEqual([u'Introdu\xefu un n\xfamero.'], form.errors['decimal_field']) 148 self.assertEqual([u'Introdu\xefu una data v\xe0lida.'], form.errors['date_field']) 149 self.assertEqual([u'Introdu\xefu una data/hora v\xe0lides.'], form.errors['datetime_field']) 150 151 form2 = SelectDateForm({ 152 'date_field_month': u'12', 153 'date_field_day': u'31', 154 'date_field_year': u'2009' 155 }) 156 self.assertEqual(True, form2.is_valid()) 157 self.assertEqual(datetime.date(2009, 12, 31), form2.cleaned_data['date_field']) 158 self.assertEqual(u'<select name="mydate_month" id="id_mydate_month">\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>', SelectDateWidget().render('mydate', datetime.date(2009, 12, 31))) 159 deactivate() 160 161 # Catalan locale 162 163 settings.USE_FORMAT_I18N = True 164 activate('ca') 165 self.assertEqual('j \de F \de Y', getformat('DATE_FORMAT')) 166 self.assertEqual(1, getformat('FIRST_DAY_OF_WEEK')) 167 self.assertEqual(',', getformat('DECIMAL_SEPARATOR')) 168 self.assertEqual(u'31 de desembre de 2009', date_format(d)) 169 self.assertEqual(u'desembre del 2009', date_format(d, 'YEAR_MONTH_FORMAT')) 170 self.assertEqual(u'31/12/2009 20:50', date_format(dt, 'SHORT_DATETIME_FORMAT')) 171 self.assertEqual('No localizable', localize('No localizable')) 172 173 settings.USE_THOUSAND_SEPARATOR = True 174 self.assertEqual(u'66.666,666', localize(n)) 175 self.assertEqual(u'99.999,999', localize(f)) 176 177 settings.USE_THOUSAND_SEPARATOR = False 178 self.assertEqual(u'66666,666', localize(n)) 179 self.assertEqual(u'99999,999', localize(f)) 180 self.assertEqual(u'31 de desembre de 2009', localize(d)) 181 self.assertEqual(u'31 de desembre de 2009 a les 20:50', localize(dt)) 182 183 settings.USE_THOUSAND_SEPARATOR = True 184 self.assertEqual(u'66.666,666', template.Template('{{ n }}').render(ctxt)) 185 self.assertEqual(u'99.999,999', template.Template('{{ f }}').render(ctxt)) 186 187 settings.USE_THOUSAND_SEPARATOR = False 188 self.assertEqual(u'66666,666', template.Template('{{ n }}').render(ctxt)) 189 self.assertEqual(u'99999,999', template.Template('{{ f }}').render(ctxt)) 190 self.assertEqual(u'31 de desembre de 2009', template.Template('{{ d }}').render(ctxt)) 191 self.assertEqual(u'31 de desembre de 2009 a les 20:50', template.Template('{{ dt }}').render(ctxt)) 192 self.assertEqual(u'66666,67', template.Template('{{ n|floatformat:2 }}').render(ctxt)) 193 self.assertEqual(u'100000,0', template.Template('{{ f|floatformat }}').render(ctxt)) 194 self.assertEqual(u'31/12/2009', template.Template('{{ d|date:"SHORT_DATE_FORMAT" }}').render(ctxt)) 195 self.assertEqual(u'31/12/2009 20:50', template.Template('{{ dt|date:"SHORT_DATETIME_FORMAT" }}').render(ctxt)) 196 197 form3 = I18nForm({ 198 'decimal_field': u'66666,666', 199 'float_field': u'99999,999', 200 'date_field': u'31/12/2009', 201 'datetime_field': u'31/12/2009 20:50', 202 'time_field': u'20:50' 203 }) 204 self.assertEqual(True, form3.is_valid()) 205 self.assertEqual(decimal.Decimal('66666.666'), form3.cleaned_data['decimal_field']) 206 self.assertEqual(99999.999, form3.cleaned_data['float_field']) 207 self.assertEqual(datetime.date(2009, 12, 31), form3.cleaned_data['date_field']) 208 self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), form3.cleaned_data['datetime_field']) 209 self.assertEqual(datetime.time(20, 50), form3.cleaned_data['time_field']) 210 211 form4 = SelectDateForm({ 212 'date_field_month': u'12', 213 'date_field_day': u'31', 214 'date_field_year': u'2009' 215 }) 216 self.assertEqual(True, form4.is_valid()) 217 self.assertEqual(datetime.date(2009, 12, 31), form4.cleaned_data['date_field']) 218 self.assertEqual(u'<select name="mydate_day" id="id_mydate_day">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_month" id="id_mydate_month">\n<option value="1">gener</option>\n<option value="2">febrer</option>\n<option value="3">mar\xe7</option>\n<option value="4">abril</option>\n<option value="5">maig</option>\n<option value="6">juny</option>\n<option value="7">juliol</option>\n<option value="8">agost</option>\n<option value="9">setembre</option>\n<option value="10">octubre</option>\n<option value="11">novembre</option>\n<option value="12" selected="selected">desembre</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>', SelectDateWidget().render('mydate', datetime.date(2009, 12, 31))) 219 deactivate() 220 221 # English locale 222 223 settings.USE_FORMAT_I18N = True 224 activate('en') 225 self.assertEqual('N j, Y', getformat('DATE_FORMAT')) 226 self.assertEqual(0, getformat('FIRST_DAY_OF_WEEK')) 227 self.assertEqual('.', getformat('DECIMAL_SEPARATOR')) 228 self.assertEqual(u'Dec. 31, 2009', date_format(d)) 229 self.assertEqual(u'December 2009', date_format(d, 'YEAR_MONTH_FORMAT')) 230 self.assertEqual(u'12/31/2009 8:50 p.m.', date_format(dt, 'SHORT_DATETIME_FORMAT')) 231 self.assertEqual('No localizable', localize('No localizable')) 232 233 settings.USE_THOUSAND_SEPARATOR = True 234 self.assertEqual(u'66,666.666', localize(n)) 235 self.assertEqual(u'99,999.999', localize(f)) 236 237 settings.USE_THOUSAND_SEPARATOR = False 238 self.assertEqual(u'66666.666', localize(n)) 239 self.assertEqual(u'99999.999', localize(f)) 240 self.assertEqual(u'Dec. 31, 2009', localize(d)) 241 self.assertEqual(u'Dec. 31, 2009, 8:50 p.m.', localize(dt)) 242 243 settings.USE_THOUSAND_SEPARATOR = True 244 self.assertEqual(u'66,666.666', template.Template('{{ n }}').render(ctxt)) 245 self.assertEqual(u'99,999.999', template.Template('{{ f }}').render(ctxt)) 246 247 settings.USE_THOUSAND_SEPARATOR = False 248 self.assertEqual(u'66666.666', template.Template('{{ n }}').render(ctxt)) 249 self.assertEqual(u'99999.999', template.Template('{{ f }}').render(ctxt)) 250 self.assertEqual(u'Dec. 31, 2009', template.Template('{{ d }}').render(ctxt)) 251 self.assertEqual(u'Dec. 31, 2009, 8:50 p.m.', template.Template('{{ dt }}').render(ctxt)) 252 self.assertEqual(u'66666.67', template.Template('{{ n|floatformat:2 }}').render(ctxt)) 253 self.assertEqual(u'100000.0', template.Template('{{ f|floatformat }}').render(ctxt)) 254 self.assertEqual(u'12/31/2009', template.Template('{{ d|date:"SHORT_DATE_FORMAT" }}').render(ctxt)) 255 self.assertEqual(u'12/31/2009 8:50 p.m.', template.Template('{{ dt|date:"SHORT_DATETIME_FORMAT" }}').render(ctxt)) 256 257 form5 = I18nForm({ 258 'decimal_field': u'66666.666', 259 'float_field': u'99999.999', 260 'date_field': u'12/31/2009', 261 'datetime_field': u'12/31/2009 20:50', 262 'time_field': u'20:50' 263 }) 264 self.assertEqual(True, form5.is_valid()) 265 self.assertEqual(decimal.Decimal('66666.666'), form5.cleaned_data['decimal_field']) 266 self.assertEqual(99999.999, form5.cleaned_data['float_field']) 267 self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field']) 268 self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), form5.cleaned_data['datetime_field']) 269 self.assertEqual(datetime.time(20, 50), form5.cleaned_data['time_field']) 270 271 form6 = SelectDateForm({ 272 'date_field_month': u'12', 273 'date_field_day': u'31', 274 'date_field_year': u'2009' 275 }) 276 self.assertEqual(True, form6.is_valid()) 277 self.assertEqual(datetime.date(2009, 12, 31), form6.cleaned_data['date_field']) 278 self.assertEqual(u'<select name="mydate_month" id="id_mydate_month">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12" selected="selected">December</option>\n</select>\n<select name="mydate_day" id="id_mydate_day">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31" selected="selected">31</option>\n</select>\n<select name="mydate_year" id="id_mydate_year">\n<option value="2009" selected="selected">2009</option>\n<option value="2010">2010</option>\n<option value="2011">2011</option>\n<option value="2012">2012</option>\n<option value="2013">2013</option>\n<option value="2014">2014</option>\n<option value="2015">2015</option>\n<option value="2016">2016</option>\n<option value="2017">2017</option>\n<option value="2018">2018</option>\n</select>', SelectDateWidget().render('mydate', datetime.date(2009, 12, 31))) 279 deactivate() 280 281 # Check if 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_FORMAT_I18N = old_use_format_i18n 294 settings.USE_THOUSAND_SEPARATOR = old_use_thousand_separator 295 296 297 class 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')