From a8705cec47b164d8e0a3b809d4be442647c56cc2 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 11 Aug 2006 19:17:46 +0000 Subject: [PATCH] Fixed #2524 -- Added i18n hooks in create_update generic views. Thanks, mir@noris.de git-svn-id: http://code.djangoproject.com/svn/django/trunk@3559 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/generic/create_update.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django/views/generic/create_update.py b/django/views/generic/create_update.py index 27ba327ff5..034253a549 100644 --- a/django/views/generic/create_update.py +++ b/django/views/generic/create_update.py @@ -6,6 +6,7 @@ from django.contrib.auth.views import redirect_to_login from django.template import RequestContext from django.http import Http404, HttpResponse, HttpResponseRedirect from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured +from django.utils.translation import gettext def create_object(request, model, template_name=None, template_loader=loader, extra_context=None, post_save_redirect=None, @@ -39,7 +40,7 @@ def create_object(request, model, template_name=None, new_object = manipulator.save(new_data) if request.user.is_authenticated(): - request.user.message_set.create(message="The %s was created successfully." % model._meta.verbose_name) + request.user.message_set.create(message=gettext("The %(verbose_name)s was created successfully.") % {"verbose_name": model._meta.verbose_name}) # Redirect to the new object: first by trying post_save_redirect, # then by obj.get_absolute_url; fail if neither works. @@ -113,7 +114,7 @@ def update_object(request, model, object_id=None, slug=None, object = manipulator.save(new_data) if request.user.is_authenticated(): - request.user.message_set.create(message="The %s was updated successfully." % model._meta.verbose_name) + request.user.message_set.create(message=gettext("The %(verbose_name)s was updated successfully.") % {"verbose_name": model._meta.verbose_name}) # Do a post-after-redirect so that reload works, etc. if post_save_redirect: @@ -180,7 +181,7 @@ def delete_object(request, model, post_delete_redirect, if request.method == 'POST': object.delete() if request.user.is_authenticated(): - request.user.message_set.create(message="The %s was deleted." % model._meta.verbose_name) + request.user.message_set.create(message=gettext("The %(verbose_name)s was deleted.") % {"verbose_name": model._meta.verbose_name}) return HttpResponseRedirect(post_delete_redirect) else: if not template_name: