From ded8bacc5d56f9c0edb5c4d2d4001cd771b59940 Mon Sep 17 00:00:00 2001
From: Andrew Stone
Date: Wed, 7 Jul 2021 15:04:51 -0700
Subject: [PATCH] Use DATETIME_FORMAT for localization in templates (#7321)
---
CHANGELOG.txt | 1 +
docs/releases/2.14.rst | 1 +
wagtail/admin/templates/wagtailadmin/home/locked_pages.html | 2 +-
.../templates/wagtailadmin/home/pages_for_moderation.html | 2 +-
wagtail/admin/templates/wagtailadmin/home/recent_edits.html | 2 +-
.../wagtailadmin/home/user_pages_in_workflow_moderation.html | 2 +-
.../wagtailadmin/home/workflow_pages_to_moderate.html | 2 +-
wagtail/admin/templates/wagtailadmin/pages/history.html | 2 +-
wagtail/admin/templates/wagtailadmin/pages/listing/_list.html | 4 ++--
.../templates/wagtailadmin/pages/workflow_history/list.html | 2 +-
.../templates/wagtailadmin/reports/listing/_list_unlock.html | 2 +-
.../admin/templates/wagtailadmin/reports/site_history.html | 2 +-
wagtail/documents/templates/wagtaildocs/documents/list.html | 2 +-
wagtail/users/templates/wagtailusers/users/list.html | 2 +-
14 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 0bf747d920..d1d81ba3cc 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -16,6 +16,7 @@ Changelog
* Add Google Data Studio to the list of oEmbed providers (Petr DlouhĂ˝)
* Added instructions on copying and aliasing pages to the editor's guide in documentation (Vlad Podgurschi)
* Allow ListBlock to raise validation errors that are not attached to an individual child block (Matt Westcott)
+ * Use `DATETIME_FORMAT` for localization in templates (Andrew Stone)
* Fix: Invalid filter values for foreign key fields in the API now give an error instead of crashing (Tidjani Dia)
* Fix: Ordering specified in `construct_explorer_page_queryset` hook is now taken into account again by the page explorer API (Andre Fonseca)
* Fix: Deleting a page from its listing view no longer results in a 404 error (Tidjani Dia)
diff --git a/docs/releases/2.14.rst b/docs/releases/2.14.rst
index b0cdfc6839..d613036423 100644
--- a/docs/releases/2.14.rst
+++ b/docs/releases/2.14.rst
@@ -24,6 +24,7 @@ Other features
* Added instructions on copying and aliasing pages to the editor's guide in documentation (Vlad Podgurschi)
* Add Google Data Studio to the list of oEmbed providers (Petr DlouhĂ˝)
* Allow ListBlock to raise validation errors that are not attached to an individual child block (Matt Westcott)
+ * Use ``DATETIME_FORMAT`` for localization in templates (Andrew Stone)
Bug fixes
~~~~~~~~~
diff --git a/wagtail/admin/templates/wagtailadmin/home/locked_pages.html b/wagtail/admin/templates/wagtailadmin/home/locked_pages.html
index 0dfd03449c..c8612550e7 100644
--- a/wagtail/admin/templates/wagtailadmin/home/locked_pages.html
+++ b/wagtail/admin/templates/wagtailadmin/home/locked_pages.html
@@ -43,7 +43,7 @@
{# Deliberately empty #} |
- {% blocktrans with time_period=page.locked_at|timesince_simple %}{{ time_period }}{% endblocktrans %} |
+ {% blocktrans with time_period=page.locked_at|timesince_simple %}{{ time_period }}{% endblocktrans %} |
{% endfor %}
diff --git a/wagtail/admin/templates/wagtailadmin/home/pages_for_moderation.html b/wagtail/admin/templates/wagtailadmin/home/pages_for_moderation.html
index 23b5debff7..2342c5a4be 100644
--- a/wagtail/admin/templates/wagtailadmin/home/pages_for_moderation.html
+++ b/wagtail/admin/templates/wagtailadmin/home/pages_for_moderation.html
@@ -61,7 +61,7 @@
{{ revision.page.content_type.model_class.get_verbose_name }}
- {% blocktrans with time_period=revision.created_at|timesince_simple %}{{ time_period }}{% endblocktrans %}
+ {% blocktrans with time_period=revision.created_at|timesince_simple %}{{ time_period }}{% endblocktrans %}
{% if revision.user %}
by {{ revision.user|user_display_name }}
{% endif %}
diff --git a/wagtail/admin/templates/wagtailadmin/home/recent_edits.html b/wagtail/admin/templates/wagtailadmin/home/recent_edits.html
index 1c90127e21..ad315b6777 100644
--- a/wagtail/admin/templates/wagtailadmin/home/recent_edits.html
+++ b/wagtail/admin/templates/wagtailadmin/home/recent_edits.html
@@ -41,7 +41,7 @@
|
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
|
- {% blocktrans with time_period=revision.created_at|timesince_simple %}{{ time_period }}{% endblocktrans %} |
+ {% blocktrans with time_period=revision.created_at|timesince_simple %}{{ time_period }}{% endblocktrans %} |
{% endfor %}
diff --git a/wagtail/admin/templates/wagtailadmin/home/user_pages_in_workflow_moderation.html b/wagtail/admin/templates/wagtailadmin/home/user_pages_in_workflow_moderation.html
index 9c9c44305d..2baacda705 100644
--- a/wagtail/admin/templates/wagtailadmin/home/user_pages_in_workflow_moderation.html
+++ b/wagtail/admin/templates/wagtailadmin/home/user_pages_in_workflow_moderation.html
@@ -41,7 +41,7 @@
{{ workflow_state.current_task_state.task.name }}
- {% blocktrans with time_period=workflow_state.current_task_state.started_at|timesince_simple %}{{ time_period }}{% endblocktrans %}
+ {% blocktrans with time_period=workflow_state.current_task_state.started_at|timesince_simple %}{{ time_period }}{% endblocktrans %}
|
{% endwith %}
diff --git a/wagtail/admin/templates/wagtailadmin/home/workflow_pages_to_moderate.html b/wagtail/admin/templates/wagtailadmin/home/workflow_pages_to_moderate.html
index 2be6103081..3b91b933ff 100644
--- a/wagtail/admin/templates/wagtailadmin/home/workflow_pages_to_moderate.html
+++ b/wagtail/admin/templates/wagtailadmin/home/workflow_pages_to_moderate.html
@@ -64,7 +64,7 @@
{% endfor %}
- {% blocktrans with time_period=task_state.started_at|timesince_simple %}{{ time_period }}{% endblocktrans %}
+ {% blocktrans with time_period=task_state.started_at|timesince_simple %}{{ time_period }}{% endblocktrans %}
|
{% endwith %}
diff --git a/wagtail/admin/templates/wagtailadmin/pages/history.html b/wagtail/admin/templates/wagtailadmin/pages/history.html
index 96ea7a3735..154cbd8e54 100644
--- a/wagtail/admin/templates/wagtailadmin/pages/history.html
+++ b/wagtail/admin/templates/wagtailadmin/pages/history.html
@@ -49,7 +49,7 @@
{% include "wagtailadmin/shared/user_avatar.html" with user=entry.user username=entry.user_display_name %}
- {% blocktrans with time_period=entry.timestamp|timesince %}{{ time_period }} ago{% endblocktrans %}
+ {% blocktrans with time_period=entry.timestamp|timesince %}{{ time_period }} ago{% endblocktrans %}
|
{% endfor %}
diff --git a/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html b/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html
index 95f76e12e4..f7cea953f1 100644
--- a/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html
+++ b/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html
@@ -24,7 +24,7 @@
{% block parent_page_title %}
{% endblock %}
- {% if parent_page.latest_revision_created_at %} {% blocktrans with time_period=parent_page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %} {% endif %} |
+ {% if parent_page.latest_revision_created_at %} {% blocktrans with time_period=parent_page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %} {% endif %} |
{% if not parent_page.is_root %}
{{ parent_page.content_type.model_class.get_verbose_name }}
@@ -65,7 +65,7 @@
{% endblock %}
|
{% endif %}
- {% if page.latest_revision_created_at %} {% blocktrans with time_period=page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %} {% endif %} |
+ {% if page.latest_revision_created_at %} {% blocktrans with time_period=page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %} {% endif %} |
{{ page.content_type.model_class.get_verbose_name }} |
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
diff --git a/wagtail/admin/templates/wagtailadmin/pages/workflow_history/list.html b/wagtail/admin/templates/wagtailadmin/pages/workflow_history/list.html
index a19f88b8b8..23600a9574 100644
--- a/wagtail/admin/templates/wagtailadmin/pages/workflow_history/list.html
+++ b/wagtail/admin/templates/wagtailadmin/pages/workflow_history/list.html
@@ -44,7 +44,7 @@
|
{{ workflow_state.requested_by|user_display_name }} |
-
+
{% blocktrans with time_period=workflow_state.created_at|timesince %}{{ time_period }} ago{% endblocktrans %}
|
diff --git a/wagtail/admin/templates/wagtailadmin/reports/listing/_list_unlock.html b/wagtail/admin/templates/wagtailadmin/reports/listing/_list_unlock.html
index 643de7d560..308b0e1346 100644
--- a/wagtail/admin/templates/wagtailadmin/reports/listing/_list_unlock.html
+++ b/wagtail/admin/templates/wagtailadmin/reports/listing/_list_unlock.html
@@ -14,7 +14,7 @@
{% page_permissions page as perms %}
{% if page.locked_at %}
- {% with page.locked_at|date:"d M Y H:i" as locking_date %}
+ {% with page.locked_at|date:"DATETIME_FORMAT" as locking_date %}
{% if page.locked_by %}
{% if page.locked_by_id == request.user.pk %}
{% blocktrans %}
diff --git a/wagtail/admin/templates/wagtailadmin/reports/site_history.html b/wagtail/admin/templates/wagtailadmin/reports/site_history.html
index d87a9e2540..c9abf1c2e1 100644
--- a/wagtail/admin/templates/wagtailadmin/reports/site_history.html
+++ b/wagtail/admin/templates/wagtailadmin/reports/site_history.html
@@ -42,7 +42,7 @@
{% include "wagtailadmin/shared/user_avatar.html" with user=entry.user username=entry.user_display_name %}
- {% blocktrans with time_period=entry.timestamp|timesince %}{{ time_period }} ago{% endblocktrans %}
+ {% blocktrans with time_period=entry.timestamp|timesince %}{{ time_period }} ago{% endblocktrans %}
|
{% endfor %}
diff --git a/wagtail/documents/templates/wagtaildocs/documents/list.html b/wagtail/documents/templates/wagtaildocs/documents/list.html
index 7bf4de209a..7b55440dd0 100644
--- a/wagtail/documents/templates/wagtaildocs/documents/list.html
+++ b/wagtail/documents/templates/wagtaildocs/documents/list.html
@@ -47,7 +47,7 @@
{{ doc.collection.name }} |
{% endif %}
-
+
{% blocktrans with time_period=doc.created_at|timesince %}{{ time_period }} ago{% endblocktrans %}
|
diff --git a/wagtail/users/templates/wagtailusers/users/list.html b/wagtail/users/templates/wagtailusers/users/list.html
index 35091ff31d..c1615eced5 100644
--- a/wagtail/users/templates/wagtailusers/users/list.html
+++ b/wagtail/users/templates/wagtailusers/users/list.html
@@ -44,7 +44,7 @@
{{ user.get_username }} |
{% if user.is_superuser %}{% trans "Admin" %}{% endif %} |
{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %} |
- {% if user.last_login %}{% blocktrans with time_period=user.last_login|timesince %}{{ time_period }} ago{% endblocktrans %}{% endif %} |
+ {% if user.last_login %}{% blocktrans with time_period=user.last_login|timesince %}{{ time_period }} ago{% endblocktrans %}{% endif %} |
{% endfor %}