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" %}
{% load i18n %}
{% block title %}Approve a comment{% endblock %}
{% block title %}{% trans "Approve a comment" %}{% endblock %}
{% block content %}
<h1>Really make this comment public?</h1>
<h1>{% trans "Really make this comment public?" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote>
<form action="." method="post">
<input type="hidden" name="next" value="{{ next }}" id="next" />
<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>
</form>
{% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for approving.{% endblock %}
{% block title %}{% trans "Thanks for approving" %}.{% endblock %}
{% 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 %}

View File

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

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for removing.{% endblock %}
{% block title %}{% trans "Thanks for removing" %}.{% endblock %}
{% 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 %}

View File

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

View File

@ -1,7 +1,8 @@
{% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Thanks for flagging.{% endblock %}
{% block title %}{% trans "Thanks for flagging" %}.{% endblock %}
{% 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 %}

View File

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

View File

@ -1,7 +1,7 @@
{% 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.super }}
@ -16,28 +16,28 @@
{% endblock %}
{% block branding %}
<h1 id="site-name">Comment moderation queue</h1>
<h1 id="site-name">{% trans "Comment moderation queue" %}</h1>
{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block content %}
{% if empty %}
<p id="nocomments">No comments to moderate.</p>
<p id="nocomments">{% trans "No comments to moderate" %}.</p>
{% else %}
<div id="content-main">
<div class="module" id="changelist">
<table cellspacing="0">
<thead>
<tr>
<th>Action</th>
<th>Name</th>
<th>Comment</th>
<th>Email</th>
<th>URL</th>
<th>Authenticated?</th>
<th>IP Address</th>
<th class="sorted desc">Date posted</th>
<th>{% trans "Action" %}</th>
<th>{% trans "Name" %}</th>
<th>{% trans "Comment" %}</th>
<th>{% trans "Email" %}</th>
<th>{% trans "URL" %}</th>
<th>{% trans "Authenticated?" %}</th>
<th>{% trans "IP Address" %}</th>
<th class="sorted desc">{% trans "Date posted" %}</th>
</tr>
</thead>
<tbody>
@ -46,11 +46,11 @@
<td class="actions">
<form action="{% url comments-approve comment.pk %}" method="post">
<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 action="{% url comments-delete comment.pk %}" method="post">
<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>
</td>
<td>{{ comment.name }}</td>
@ -60,7 +60,7 @@
<td>
<img
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>{{ comment.ip_address }}</td>

View File

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

View File

@ -1,17 +1,18 @@
{% extends "comments/base.html" %}
{% load i18n %}
{% block title %}Preview your comment{% endblock %}
{% block title %}{% trans "Preview your comment" %}{% endblock %}
{% block content %}
{% load comments %}
<form action="{% comment_form_target %}" method="post">
{% 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 %}
<h1>Preview your comment</h1>
<h1>{% trans "Preview your comment" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote>
<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>
{% endif %}
{% for field in form %}
@ -27,8 +28,8 @@
{% endif %}
{% endfor %}
<p class="submit">
<input type="submit" name="submit" class="submit-post" value="Post" />
<input type="submit" name="submit" class="submit-preview" value="Preview" />
<input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
<input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
</p>
</form>
{% endblock %}

View File

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

View File

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