diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b0cbd103e4..e1e2275a19 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -9,6 +9,7 @@ Changelog * Refactor redirects edit view to use the generic `EditView` and breadcrumbs (Rohit Sharma) * Fix: Make `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` setting functional again (Rohit Sharma) * Fix: Enable `richtext` template tag to convert lazy translation values (Benjamin Bach) + * Fix: Ensure permission labels on group permissions page are translated where available (Matt Westcott) * Docs: Remove duplicate section on frontend caching proxies from performance page (Jake Howard) * Maintenance: Use `DjangoJSONEncoder` instead of custom `LazyStringEncoder` to serialize Draftail config (Sage Abdullah) diff --git a/docs/releases/6.2.md b/docs/releases/6.2.md index 60c8040e18..20a929f80a 100644 --- a/docs/releases/6.2.md +++ b/docs/releases/6.2.md @@ -22,6 +22,7 @@ depth: 1 * Make `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` setting functional again (Rohit Sharma) * Enable `richtext` template tag to convert lazy translation values (Benjamin Bach) + * Ensure permission labels on group permissions page are translated where available (Matt Westcott) ### Documentation diff --git a/wagtail/admin/models.py b/wagtail/admin/models.py index c9e0bc8220..b4fae5524a 100644 --- a/wagtail/admin/models.py +++ b/wagtail/admin/models.py @@ -1,5 +1,6 @@ from django.contrib.contenttypes.models import ContentType from django.db.models import Count, Model +from django.utils.translation import gettext_lazy as _ from modelcluster.fields import ParentalKey from taggit.models import Tag @@ -18,7 +19,7 @@ class Admin(Model): class Meta: default_permissions = [] # don't create the default add / change / delete / view perms permissions = [ - ("access_admin", "Can access Wagtail admin"), + ("access_admin", _("Can access Wagtail admin")), ] diff --git a/wagtail/contrib/simple_translation/models.py b/wagtail/contrib/simple_translation/models.py index 04cc6535f7..3e8aa0e8ba 100644 --- a/wagtail/contrib/simple_translation/models.py +++ b/wagtail/contrib/simple_translation/models.py @@ -1,5 +1,6 @@ from django.conf import settings from django.db.models import Model +from django.utils.translation import gettext_lazy as _ from wagtail import hooks from wagtail.models import Locale @@ -17,7 +18,7 @@ class SimpleTranslation(Model): class Meta: default_permissions = [] permissions = [ - ("submit_translation", "Can submit translations"), + ("submit_translation", _("Can submit translations")), ] diff --git a/wagtail/users/templates/wagtailusers/groups/includes/formatted_permissions.html b/wagtail/users/templates/wagtailusers/groups/includes/formatted_permissions.html index 50e272ca56..7d4a9ed286 100644 --- a/wagtail/users/templates/wagtailusers/groups/includes/formatted_permissions.html +++ b/wagtail/users/templates/wagtailusers/groups/includes/formatted_permissions.html @@ -96,7 +96,8 @@
{% trans "Custom permissions" %} {% for custom_perm in content_perms_dict.custom %} - {% include "wagtailadmin/shared/forms/single_checkbox.html" with name="permissions" value=custom_perm.perm.id checked=custom_perm.selected text=custom_perm.name attrs=custom_perm.attrs %} + {% trans custom_perm.name as custom_perm_label %} + {% include "wagtailadmin/shared/forms/single_checkbox.html" with name="permissions" value=custom_perm.perm.id checked=custom_perm.selected text=custom_perm_label attrs=custom_perm.attrs %} {% endfor %}
{% endif %} @@ -170,7 +171,7 @@ {% for perm_tuple in other_perms %} - + {{ perm_tuple.1.tag }} diff --git a/wagtail/users/templatetags/wagtailusers_tags.py b/wagtail/users/templatetags/wagtailusers_tags.py index bc4f6b922f..e9966c6ebb 100644 --- a/wagtail/users/templatetags/wagtailusers_tags.py +++ b/wagtail/users/templatetags/wagtailusers_tags.py @@ -6,6 +6,7 @@ from django.contrib.auth import get_permission_codename from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.utils.text import camel_case_to_spaces +from django.utils.translation import gettext_noop from wagtail import hooks from wagtail.admin.models import Admin @@ -55,6 +56,14 @@ def normalize_permission_label(permission: Permission): return label +# normalize_permission_label will return "Can view" for Django's standard "Can view X" permission. +# formatted_permissions.html passes these labels through {% trans %} - since this is a variable +# within the template it will not be picked up by makemessages, so we define a translation here +# instead. + +VIEW_PERMISSION_LABEL = gettext_noop("Can view") + + @register.inclusion_tag("wagtailusers/groups/includes/formatted_permissions.html") def format_permissions(permission_bound_field): """