Author: russellm
Date: 2010-03-12 09:32:06 -0600 (Fri, 12 Mar 2010)
New Revision: 12770

Modified:
   django/trunk/django/contrib/comments/admin.py
Log:
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.

Modified: django/trunk/django/contrib/comments/admin.py
===================================================================
--- django/trunk/django/contrib/comments/admin.py       2010-03-12 15:24:28 UTC 
(rev 12769)
+++ django/trunk/django/contrib/comments/admin.py       2010-03-12 15:32:06 UTC 
(rev 12770)
@@ -36,18 +36,21 @@
         return actions
 
     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")
 
     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")
 
     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")
 
-    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
         calls the `action` argument to perform the heavy lifting.
@@ -56,11 +59,11 @@
         for comment in queryset:
             action(request, comment)
             n_comments += 1
-        
+
         msg = ungettext(u'1 comment was successfully %(action)s.',
                         u'%(count)s comments were successfully %(action)s.',
                         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
 # (this won't be true if there's a custom comment app).

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to