From c997c6b9aaaffeaa7d1d5d0aca3d7d644a270db1 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 20 Aug 2020 10:12:33 +0200 Subject: [PATCH] Fix pluralization in check pending --- .../management/commands/check_pending_comments.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/articles/management/commands/check_pending_comments.py b/articles/management/commands/check_pending_comments.py index 8e90f8d..c35a8d3 100644 --- a/articles/management/commands/check_pending_comments.py +++ b/articles/management/commands/check_pending_comments.py @@ -2,6 +2,7 @@ from django.conf import settings from django.core.mail import mail_admins from django.core.management import BaseCommand from django.urls import reverse +from django.utils.translation import ngettext from articles.models import Comment @@ -16,8 +17,9 @@ class Command(BaseCommand): url = (settings.BLOG["base_url"] + url).replace( "//", "/" ) + "?status__exact=pending" - comments = "comment" - if count > 1: - comments += "s" - message = f"There are {count} {comments} pending review.\n{url}" - mail_admins("Comments pending", message) + message = ngettext( + "There is %(count)d comment pending review.\n%(url)s", + "There are %(count)d comments pending review.\n%(url)s", + count, + ) % {"count": count, "url": url} + mail_admins("Comments pending review", message)