Skip to content

Commit 57f9982

Browse files
committed
Refs #35306 -- Tested unlocalize honor settings.DATE_FORMAT.
1 parent b6e2b83 commit 57f9982

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/i18n/tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,23 @@ def test_localize_templatetag_and_filter(self):
13511351
self.assertEqual(template2.render(context), output2)
13521352
self.assertEqual(template3.render(context), output3)
13531353

1354+
def test_unlocalize_honor_date_settings(self):
1355+
filter_template = Template(
1356+
"{% load l10n %}Localized: {{ date }}. Unlocalized: {{ date|unlocalize }}."
1357+
)
1358+
tag_template = Template(
1359+
"{% load l10n %}Localized: {{ date }}. {% localize off %}Unlocalized: "
1360+
"{{ date }}{% endlocalize %}."
1361+
)
1362+
context = Context({"date": datetime.date(2024, 12, 15)})
1363+
expected_result = "Localized: 15. Dezember 2024. Unlocalized: 15-12-2024."
1364+
with (
1365+
translation.override("de", deactivate=True),
1366+
self.settings(DATE_FORMAT="j-m-Y"),
1367+
):
1368+
self.assertEqual(filter_template.render(context), expected_result)
1369+
self.assertEqual(tag_template.render(context), expected_result)
1370+
13541371
def test_localized_off_numbers(self):
13551372
"""A string representation is returned for unlocalized numbers."""
13561373
template = Template(

0 commit comments

Comments
 (0)