Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12940 -- Modified some admin actions in contrib.comments to us…

…e 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
  • Loading branch information...
commit fbf00078e1bdd702f95c7b56277fe602b3bda9e1 1 parent 75c8c1d
Russell Keith-Magee authored March 12, 2010

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  django/contrib/comments/admin.py
15  django/contrib/comments/admin.py
@@ -36,18 +36,21 @@ def get_actions(self, request):
36 36
         return actions
37 37
 
38 38
     def flag_comments(self, request, queryset):
39  
-        self._bulk_flag(request, queryset, perform_flag, _("flagged"))
  39
+        self._bulk_flag(request, queryset, perform_flag,
  40
+                        lambda n: ungettext('flagged', 'flagged', n))
40 41
     flag_comments.short_description = _("Flag selected comments")
41 42
 
42 43
     def approve_comments(self, request, queryset):
43  
-        self._bulk_flag(request, queryset, perform_approve, _('approved'))
  44
+        self._bulk_flag(request, queryset, perform_approve,
  45
+                        lambda n: ungettext('approved', 'approved', n))
44 46
     approve_comments.short_description = _("Approve selected comments")
45 47
 
46 48
     def remove_comments(self, request, queryset):
47  
-        self._bulk_flag(request, queryset, perform_delete, _('removed'))
  49
+        self._bulk_flag(request, queryset, perform_delete,
  50
+                        lambda n: ungettext('removed', 'removed', n))
48 51
     remove_comments.short_description = _("Remove selected comments")
49 52
 
50  
-    def _bulk_flag(self, request, queryset, action, description):
  53
+    def _bulk_flag(self, request, queryset, action, done_message):
51 54
         """
52 55
         Flag, approve, or remove some comments from an admin action. Actually
53 56
         calls the `action` argument to perform the heavy lifting.
@@ -56,11 +59,11 @@ def _bulk_flag(self, request, queryset, action, description):
56 59
         for comment in queryset:
57 60
             action(request, comment)
58 61
             n_comments += 1
59  
-        
  62
+
60 63
         msg = ungettext(u'1 comment was successfully %(action)s.',
61 64
                         u'%(count)s comments were successfully %(action)s.',
62 65
                         n_comments)
63  
-        self.message_user(request, msg % {'count': n_comments, 'action': description})
  66
+        self.message_user(request, msg % {'count': n_comments, 'action': done_message(n_comments)})
64 67
 
65 68
 # Only register the default admin if the model is the built-in comment model
66 69
 # (this won't be true if there's a custom comment app).

0 notes on commit fbf0007

Please sign in to comment.
Something went wrong with that request. Please try again.