diff --git a/django/views/i18n.py b/django/views/i18n.py index ce78742fd8d..261d66fe8c8 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -8,7 +8,6 @@ from django.conf import settings from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.template import Context, Engine from django.urls import translate_url -from django.utils.encoding import force_text from django.utils.formats import get_format from django.utils.http import is_safe_url from django.utils.translation import ( @@ -68,16 +67,7 @@ def get_formats(): 'THOUSAND_SEPARATOR', 'NUMBER_GROUPING', 'DATE_INPUT_FORMATS', 'TIME_INPUT_FORMATS', 'DATETIME_INPUT_FORMATS' ) - result = {} - for attr in FORMAT_SETTINGS: - result[attr] = get_format(attr) - formats = {} - for k, v in result.items(): - if isinstance(v, (int, str)): - formats[k] = force_text(v) - elif isinstance(v, (tuple, list)): - formats[k] = [force_text(value) for value in v] - return formats + return {attr: get_format(attr) for attr in FORMAT_SETTINGS} js_catalog_template = r""" diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 5afe526d134..450d8bd3da4 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -326,6 +326,9 @@ Miscellaneous require them. Third-party apps that use these methods may want to adopt a similar approach. +* The ``FIRST_DAY_OF_WEEK`` and ``NUMBER_GROUPING`` format settings are now + kept as integers in JavaScript and JSON i18n view outputs. + .. _deprecated-features-2.0: Features deprecated in 2.0 diff --git a/js_tests/admin/jsi18n-mocks.test.js b/js_tests/admin/jsi18n-mocks.test.js index 4858de6eb36..f04b0576f65 100644 --- a/js_tests/admin/jsi18n-mocks.test.js +++ b/js_tests/admin/jsi18n-mocks.test.js @@ -53,9 +53,9 @@ "%m/%d/%y" ], "DECIMAL_SEPARATOR": ".", - "FIRST_DAY_OF_WEEK": "0", + "FIRST_DAY_OF_WEEK": 0, "MONTH_DAY_FORMAT": "F j", - "NUMBER_GROUPING": "3", + "NUMBER_GROUPING": 3, "SHORT_DATETIME_FORMAT": "m/d/Y P", "SHORT_DATE_FORMAT": "m/d/Y", "THOUSAND_SEPARATOR": ",", diff --git a/tests/view_tests/templates/jsi18n.html b/tests/view_tests/templates/jsi18n.html index d6093c8ef4a..df1c4b400c7 100644 --- a/tests/view_tests/templates/jsi18n.html +++ b/tests/view_tests/templates/jsi18n.html @@ -4,6 +4,14 @@ +

+ +

+