Add internationalisation support to the comment templates. Fixed #8868, #8905

Thanks to zgoda for a patch that did most of the internationalisation part.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9119 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-10-05 05:09:21 +00:00
parent 227a93b64f
commit 8524089769
12 changed files with 56 additions and 49 deletions

View File

@ -1,14 +1,15 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Approve a comment{% endblock %} {% block title %}{% trans "Approve a comment" %}{% endblock %}
{% block content %} {% block content %}
<h1>Really make this comment public?</h1> <h1>{% trans "Really make this comment public?" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote> <blockquote>{{ comment|linebreaks }}</blockquote>
<form action="." method="post"> <form action="." method="post">
<input type="hidden" name="next" value="{{ next }}" id="next" /> <input type="hidden" name="next" value="{{ next }}" id="next" />
<p class="submit"> <p class="submit">
<input type="submit" name="submit" value="Approve" /> or <a href="{{ comment.permalink }}">cancel</a> <input type="submit" name="submit" value="{% trans "Approve" %}" /> or <a href="{{ comment.permalink }}">cancel</a>
</p> </p>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for approving.{% endblock %} {% block title %}{% trans "Thanks for approving" %}.{% endblock %}
{% block content %} {% block content %}
<h1>Thanks for taking the time to improve the quality of discussion on our site.</h1> <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
{% endblock %} {% endblock %}

View File

@ -1,14 +1,15 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Remove a comment{% endblock %} {% block title %}{% trans "Remove a comment" %}{% endblock %}
{% block content %} {% block content %}
<h1>Really remove this comment?</h1> <h1>{% trans "Really remove this comment?" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote> <blockquote>{{ comment|linebreaks }}</blockquote>
<form action="." method="post"> <form action="." method="post">
<input type="hidden" name="next" value="{{ next }}" id="next" /> <input type="hidden" name="next" value="{{ next }}" id="next" />
<p class="submit"> <p class="submit">
<input type="submit" name="submit" value="Remove" /> or <a href="{{ comment.permalink }}">cancel</a> <input type="submit" name="submit" value="{% trans "Remove" %}" /> or <a href="{{ comment.permalink }}">cancel</a>
</p> </p>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for removing.{% endblock %} {% block title %}{% trans "Thanks for removing" %}.{% endblock %}
{% block content %} {% block content %}
<h1>Thanks for taking the time to improve the quality of discussion on our site.</h1> <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
{% endblock %} {% endblock %}

View File

@ -1,14 +1,15 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Flag this comment{% endblock %} {% block title %}{% trans "Flag this comment" %}{% endblock %}
{% block content %} {% block content %}
<h1>Really flag this comment?</h1> <h1>{% trans "Really flag this comment?" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote> <blockquote>{{ comment|linebreaks }}</blockquote>
<form action="." method="post"> <form action="." method="post">
<input type="hidden" name="next" value="{{ next }}" id="next" /> <input type="hidden" name="next" value="{{ next }}" id="next" />
<p class="submit"> <p class="submit">
<input type="submit" name="submit" value="Flag" /> or <a href="{{ comment.permalink }}">cancel</a> <input type="submit" name="submit" value="{% trans "Flag" %}" /> or <a href="{{ comment.permalink }}">cancel</a>
</p> </p>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for flagging.{% endblock %} {% block title %}{% trans "Thanks for flagging" %}.{% endblock %}
{% block content %} {% block content %}
<h1>Thanks for taking the time to improve the quality of discussion on our site.</h1> <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
{% endblock %} {% endblock %}

View File

@ -1,4 +1,4 @@
{% load comments %} {% load comments i18n %}
<form action="{% comment_form_target %}" method="post"> <form action="{% comment_form_target %}" method="post">
{% for field in form %} {% for field in form %}
{% if field.is_hidden %} {% if field.is_hidden %}
@ -13,7 +13,7 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<p class="submit"> <p class="submit">
<input type="submit" name="submit" class="submit-post" value="Post" /> <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
<input type="submit" name="submit" class="submit-preview" value="Preview" /> <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
</p> </p>
</form> </form>

View File

@ -1,7 +1,7 @@
{% extends "admin/change_list.html" %} {% extends "admin/change_list.html" %}
{% load adminmedia %} {% load adminmedia i18n %}
{% block title %}Comment moderation queue{% endblock %} {% block title %}{% trans "Comment moderation queue" %}{% endblock %}
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
@ -16,28 +16,28 @@
{% endblock %} {% endblock %}
{% block branding %} {% block branding %}
<h1 id="site-name">Comment moderation queue</h1> <h1 id="site-name">{% trans "Comment moderation queue" %}</h1>
{% endblock %} {% endblock %}
{% block breadcrumbs %}{% endblock %} {% block breadcrumbs %}{% endblock %}
{% block content %} {% block content %}
{% if empty %} {% if empty %}
<p id="nocomments">No comments to moderate.</p> <p id="nocomments">{% trans "No comments to moderate" %}.</p>
{% else %} {% else %}
<div id="content-main"> <div id="content-main">
<div class="module" id="changelist"> <div class="module" id="changelist">
<table cellspacing="0"> <table cellspacing="0">
<thead> <thead>
<tr> <tr>
<th>Action</th> <th>{% trans "Action" %}</th>
<th>Name</th> <th>{% trans "Name" %}</th>
<th>Comment</th> <th>{% trans "Comment" %}</th>
<th>Email</th> <th>{% trans "Email" %}</th>
<th>URL</th> <th>{% trans "URL" %}</th>
<th>Authenticated?</th> <th>{% trans "Authenticated?" %}</th>
<th>IP Address</th> <th>{% trans "IP Address" %}</th>
<th class="sorted desc">Date posted</th> <th class="sorted desc">{% trans "Date posted" %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -46,11 +46,11 @@
<td class="actions"> <td class="actions">
<form action="{% url comments-approve comment.pk %}" method="post"> <form action="{% url comments-approve comment.pk %}" method="post">
<input type="hidden" name="next" value="{% url comments-moderation-queue %}" /> <input type="hidden" name="next" value="{% url comments-moderation-queue %}" />
<input class="approve submit" type="submit" name="submit" value="Approve" /> <input class="approve submit" type="submit" name="submit" value="{% trans "Approve" %}" />
</form> </form>
<form action="{% url comments-delete comment.pk %}" method="post"> <form action="{% url comments-delete comment.pk %}" method="post">
<input type="hidden" name="next" value="{% url comments-moderation-queue %}" /> <input type="hidden" name="next" value="{% url comments-moderation-queue %}" />
<input class="remove submit" type="submit" name="submit" value="Remove" /> <input class="remove submit" type="submit" name="submit" value="{% trans "Remove" %}" />
</form> </form>
</td> </td>
<td>{{ comment.name }}</td> <td>{{ comment.name }}</td>
@ -60,7 +60,7 @@
<td> <td>
<img <img
src="{% admin_media_prefix %}img/admin/icon-{% if comment.user %}yes{% else %}no{% endif %}.gif" src="{% admin_media_prefix %}img/admin/icon-{% if comment.user %}yes{% else %}no{% endif %}.gif"
alt="{% if comment.user %}yes{% else %}no{% endif %}" alt="{% if comment.user %}{% trans "yes" %}{% else %}{% trans "no" %}{% endif %}"
/> />
</td> </td>
<td>{{ comment.ip_address }}</td> <td>{{ comment.ip_address }}</td>

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for commenting.{% endblock %} {% block title %}{% trans "Thanks for commenting" %}.{% endblock %}
{% block content %} {% block content %}
<h1>Thank you for your comment.</h1> <h1>{% trans "Thank you for your comment" %}.</h1>
{% endblock %} {% endblock %}

View File

@ -1,17 +1,18 @@
{% extends "comments/base.html" %} {% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Preview your comment{% endblock %} {% block title %}{% trans "Preview your comment" %}{% endblock %}
{% block content %} {% block content %}
{% load comments %} {% load comments %}
<form action="{% comment_form_target %}" method="post"> <form action="{% comment_form_target %}" method="post">
{% if form.errors %} {% if form.errors %}
<h1>Please correct the error{{ form.errors|pluralize }} below</h1> <h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1>
{% else %} {% else %}
<h1>Preview your comment</h1> <h1>{% trans "Preview your comment" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote> <blockquote>{{ comment|linebreaks }}</blockquote>
<p> <p>
and <input type="submit" name="submit" value="Post your comment" id="submit" /> or make changes: {% trans "and" %} <input type="submit" name="submit" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
</p> </p>
{% endif %} {% endif %}
{% for field in form %} {% for field in form %}
@ -27,8 +28,8 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<p class="submit"> <p class="submit">
<input type="submit" name="submit" class="submit-post" value="Post" /> <input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
<input type="submit" name="submit" class="submit-preview" value="Preview" /> <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
</p> </p>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -62,8 +62,7 @@ def post_comment(request, next=None):
(escape(ctype), escape(object_pk))) (escape(ctype), escape(object_pk)))
# Do we want to preview the comment? # Do we want to preview the comment?
preview = data.get("submit", "").lower() == "preview" or \ preview = "preview" in data
data.get("preview", None) is not None
# Construct the comment form # Construct the comment form
form = comments.get_form()(target, data=data) form = comments.get_form()(target, data=data)

View File

@ -45,7 +45,7 @@ class CommentViewTests(CommentTestCase):
def testCommentPreview(self): def testCommentPreview(self):
a = Article.objects.get(pk=1) a = Article.objects.get(pk=1)
data = self.getValidData(a) data = self.getValidData(a)
data["submit"] = "preview" data["preview"] = "Preview"
response = self.client.post("/post/", data) response = self.client.post("/post/", data)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "comments/preview.html") self.assertTemplateUsed(response, "comments/preview.html")