Fixed #12940 -- Modified some admin actions in contrib.comments to use ungettext in order to support Russian (and similar) pluralization rules. Thanks to void for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12770 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
75c8c1de9a
commit
fbf00078e1
@ -36,18 +36,21 @@ class CommentsAdmin(admin.ModelAdmin):
|
|||||||
return actions
|
return actions
|
||||||
|
|
||||||
def flag_comments(self, request, queryset):
|
def flag_comments(self, request, queryset):
|
||||||
self._bulk_flag(request, queryset, perform_flag, _("flagged"))
|
self._bulk_flag(request, queryset, perform_flag,
|
||||||
|
lambda n: ungettext('flagged', 'flagged', n))
|
||||||
flag_comments.short_description = _("Flag selected comments")
|
flag_comments.short_description = _("Flag selected comments")
|
||||||
|
|
||||||
def approve_comments(self, request, queryset):
|
def approve_comments(self, request, queryset):
|
||||||
self._bulk_flag(request, queryset, perform_approve, _('approved'))
|
self._bulk_flag(request, queryset, perform_approve,
|
||||||
|
lambda n: ungettext('approved', 'approved', n))
|
||||||
approve_comments.short_description = _("Approve selected comments")
|
approve_comments.short_description = _("Approve selected comments")
|
||||||
|
|
||||||
def remove_comments(self, request, queryset):
|
def remove_comments(self, request, queryset):
|
||||||
self._bulk_flag(request, queryset, perform_delete, _('removed'))
|
self._bulk_flag(request, queryset, perform_delete,
|
||||||
|
lambda n: ungettext('removed', 'removed', n))
|
||||||
remove_comments.short_description = _("Remove selected comments")
|
remove_comments.short_description = _("Remove selected comments")
|
||||||
|
|
||||||
def _bulk_flag(self, request, queryset, action, description):
|
def _bulk_flag(self, request, queryset, action, done_message):
|
||||||
"""
|
"""
|
||||||
Flag, approve, or remove some comments from an admin action. Actually
|
Flag, approve, or remove some comments from an admin action. Actually
|
||||||
calls the `action` argument to perform the heavy lifting.
|
calls the `action` argument to perform the heavy lifting.
|
||||||
@ -60,7 +63,7 @@ class CommentsAdmin(admin.ModelAdmin):
|
|||||||
msg = ungettext(u'1 comment was successfully %(action)s.',
|
msg = ungettext(u'1 comment was successfully %(action)s.',
|
||||||
u'%(count)s comments were successfully %(action)s.',
|
u'%(count)s comments were successfully %(action)s.',
|
||||||
n_comments)
|
n_comments)
|
||||||
self.message_user(request, msg % {'count': n_comments, 'action': description})
|
self.message_user(request, msg % {'count': n_comments, 'action': done_message(n_comments)})
|
||||||
|
|
||||||
# Only register the default admin if the model is the built-in comment model
|
# Only register the default admin if the model is the built-in comment model
|
||||||
# (this won't be true if there's a custom comment app).
|
# (this won't be true if there's a custom comment app).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user