Fix gettext calls in wagtail.admin.views.generic.models that should be gettext_lazy (#10539)

Fix some gettext calls that should be gettext_lazy, because they're evaluated at the module level rather than per-request - getting this wrong means that these strings will always be in whatever language was set at the server level at startup, ignoring user preferences.
pull/10550/head
Matt Westcott 2023-06-10 16:35:53 +01:00
rodzic 8bc31fc31c
commit 2a38248c6b
3 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -14,6 +14,7 @@ Changelog
* Fix: Fix missing link to `UsageView` from `EditView` for snippets (Christer Jensen)
* Fix: Prevent lowercase conversions of IndexView column headers (Virag Jain)
* Fix: Ensure that `RichText` objects with the same values compare as equal (NikilTn)
* Fix: Use `gettext_lazy` on generic model views so that language settings are correctly used (Matt Westcott)
* Docs: Document how to add non-ModelAdmin views to a `ModelAdminGroup` (Onno Timmerman)
* Docs: Document how to add StructBlock data to a StreamField (Ramon Wenger)
* Docs: Update ReadTheDocs settings to v2 to resolve urllib3 issue in linkcheck extension (Thibaud Colas)

Wyświetl plik

@ -29,6 +29,7 @@ FieldPanels can now be marked as read-only with the `read_only=True` keyword arg
* Fix missing link to `UsageView` from `EditView` for snippets (Christer Jensen)
* Prevent lowercase conversions of IndexView column headers (Virag Jain)
* Ensure that `RichText` objects with the same values compare as equal (NikilTn)
* Use `gettext_lazy` on generic model views so that language settings are correctly used (Matt Westcott)
### Documentation

Wyświetl plik

@ -77,7 +77,7 @@ class IndexView(
index_url_name = None
index_results_url_name = None
add_url_name = None
add_item_label = _("Add")
add_item_label = gettext_lazy("Add")
edit_url_name = None
template_name = "wagtailadmin/generic/index.html"
results_template_name = "wagtailadmin/generic/index_results.html"
@ -867,7 +867,7 @@ class UnpublishView(HookResponseMixin, WagtailAdminTemplateMixin, TemplateView):
edit_url_name = None
unpublish_url_name = None
usage_url_name = None
success_message = _("'%(object)s' unpublished.")
success_message = gettext_lazy("'%(object)s' unpublished.")
template_name = "wagtailadmin/generic/confirm_unpublish.html"
def setup(self, request, pk, *args, **kwargs):