Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Add internationalisation support to the comment templates. Fi…

…xed #8868, #8905

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

Backport of r9119 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9126 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ccc2387fd21f5a93e8467f2fbb6462c6fae195c5 1 parent 3893070
Malcolm Tredinnick authored October 05, 2008
7  django/contrib/comments/templates/comments/approve.html
... ...
@@ -1,14 +1,15 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Approve a comment{% endblock %}
  4
+{% block title %}{% trans "Approve a comment" %}{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Really make this comment public?</h1>
  7
+  <h1>{% trans "Really make this comment public?" %}</h1>
7 8
   <blockquote>{{ comment|linebreaks }}</blockquote>
8 9
   <form action="." method="post">
9 10
     <input type="hidden" name="next" value="{{ next }}" id="next" />
10 11
     <p class="submit">
11  
-      <input type="submit" name="submit" value="Approve" /> or <a href="{{ comment.permalink }}">cancel</a>
  12
+      <input type="submit" name="submit" value="{% trans "Approve" %}" /> or <a href="{{ comment.permalink }}">cancel</a>
12 13
     </p>
13 14
   </form>
14 15
 {% endblock %}
7  django/contrib/comments/templates/comments/approved.html
... ...
@@ -1,7 +1,8 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Thanks for approving.{% endblock %}
  4
+{% block title %}{% trans "Thanks for approving" %}.{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Thanks for taking the time to improve the quality of discussion on our site.</h1>
7  
-{% endblock %}
  7
+  <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
  8
+{% endblock %}
7  django/contrib/comments/templates/comments/delete.html
... ...
@@ -1,14 +1,15 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Remove a comment{% endblock %}
  4
+{% block title %}{% trans "Remove a comment" %}{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Really remove this comment?</h1>
  7
+<h1>{% trans "Really remove this comment?" %}</h1>
7 8
   <blockquote>{{ comment|linebreaks }}</blockquote>
8 9
   <form action="." method="post">
9 10
     <input type="hidden" name="next" value="{{ next }}" id="next" />
10 11
     <p class="submit">
11  
-      <input type="submit" name="submit" value="Remove" /> or <a href="{{ comment.permalink }}">cancel</a>
  12
+    <input type="submit" name="submit" value="{% trans "Remove" %}" /> or <a href="{{ comment.permalink }}">cancel</a>
12 13
     </p>
13 14
   </form>
14 15
 {% endblock %}
7  django/contrib/comments/templates/comments/deleted.html
... ...
@@ -1,7 +1,8 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Thanks for removing.{% endblock %}
  4
+{% block title %}{% trans "Thanks for removing" %}.{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Thanks for taking the time to improve the quality of discussion on our site.</h1>
7  
-{% endblock %}
  7
+  <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
  8
+{% endblock %}
7  django/contrib/comments/templates/comments/flag.html
... ...
@@ -1,14 +1,15 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Flag this comment{% endblock %}
  4
+{% block title %}{% trans "Flag this comment" %}{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Really flag this comment?</h1>
  7
+<h1>{% trans "Really flag this comment?" %}</h1>
7 8
   <blockquote>{{ comment|linebreaks }}</blockquote>
8 9
   <form action="." method="post">
9 10
     <input type="hidden" name="next" value="{{ next }}" id="next" />
10 11
     <p class="submit">
11  
-      <input type="submit" name="submit" value="Flag" /> or <a href="{{ comment.permalink }}">cancel</a>
  12
+    <input type="submit" name="submit" value="{% trans "Flag" %}" /> or <a href="{{ comment.permalink }}">cancel</a>
12 13
     </p>
13 14
   </form>
14 15
 {% endblock %}
7  django/contrib/comments/templates/comments/flagged.html
... ...
@@ -1,7 +1,8 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Thanks for flagging.{% endblock %}
  4
+{% block title %}{% trans "Thanks for flagging" %}.{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Thanks for taking the time to improve the quality of discussion on our site.</h1>
7  
-{% endblock %}
  7
+  <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
  8
+{% endblock %}
6  django/contrib/comments/templates/comments/form.html
... ...
@@ -1,4 +1,4 @@
1  
-{% load comments %}
  1
+{% load comments i18n %}
2 2
 <form action="{% comment_form_target %}" method="post">
3 3
   {% for field in form %}
4 4
     {% if field.is_hidden %}
@@ -13,7 +13,7 @@
13 13
     {% endif %}
14 14
   {% endfor %}
15 15
   <p class="submit">
16  
-    <input type="submit" name="submit" class="submit-post" value="Post" />
17  
-    <input type="submit" name="submit" class="submit-preview" value="Preview" />
  16
+    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
  17
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
18 18
   </p>
19 19
 </form>
30  django/contrib/comments/templates/comments/moderation_queue.html
... ...
@@ -1,7 +1,7 @@
1 1
 {% extends "admin/change_list.html" %}
2  
-{% load adminmedia %}
  2
+{% load adminmedia i18n %}
3 3
 
4  
-{% block title %}Comment moderation queue{% endblock %}
  4
+{% block title %}{% trans "Comment moderation queue" %}{% endblock %}
5 5
 
6 6
 {% block extrahead %}
7 7
   {{ block.super }}
@@ -16,28 +16,28 @@
16 16
 {% endblock %}
17 17
 
18 18
 {% block branding %}
19  
-<h1 id="site-name">Comment moderation queue</h1>
  19
+<h1 id="site-name">{% trans "Comment moderation queue" %}</h1>
20 20
 {% endblock %}
21 21
 
22 22
 {% block breadcrumbs %}{% endblock %}
23 23
 
24 24
 {% block content %}
25 25
 {% if empty %}
26  
-  <p id="nocomments">No comments to moderate.</p>
  26
+<p id="nocomments">{% trans "No comments to moderate" %}.</p>
27 27
 {% else %}
28 28
 <div id="content-main">
29 29
   <div class="module" id="changelist">
30 30
     <table cellspacing="0">
31 31
       <thead>
32 32
         <tr>
33  
-          <th>Action</th>
34  
-          <th>Name</th>
35  
-          <th>Comment</th>
36  
-          <th>Email</th>
37  
-          <th>URL</th>
38  
-          <th>Authenticated?</th>
39  
-          <th>IP Address</th>
40  
-          <th class="sorted desc">Date posted</th>
  33
+          <th>{% trans "Action" %}</th>
  34
+          <th>{% trans "Name" %}</th>
  35
+          <th>{% trans "Comment" %}</th>
  36
+          <th>{% trans "Email" %}</th>
  37
+          <th>{% trans "URL" %}</th>
  38
+          <th>{% trans "Authenticated?" %}</th>
  39
+          <th>{% trans "IP Address" %}</th>
  40
+          <th class="sorted desc">{% trans "Date posted" %}</th>
41 41
         </tr>
42 42
     </thead>
43 43
     <tbody>
@@ -46,11 +46,11 @@ <h1 id="site-name">Comment moderation queue</h1>
46 46
           <td class="actions">
47 47
             <form action="{% url comments-approve comment.pk %}" method="post">
48 48
               <input type="hidden" name="next" value="{% url comments-moderation-queue %}" />
49  
-              <input class="approve submit" type="submit" name="submit" value="Approve" />
  49
+              <input class="approve submit" type="submit" name="submit" value="{% trans "Approve" %}" />
50 50
             </form>
51 51
             <form action="{% url comments-delete comment.pk %}" method="post">
52 52
               <input type="hidden" name="next" value="{% url comments-moderation-queue %}" />
53  
-              <input class="remove submit" type="submit" name="submit" value="Remove" />
  53
+              <input class="remove submit" type="submit" name="submit" value="{% trans "Remove" %}" />
54 54
             </form>
55 55
           </td>
56 56
           <td>{{ comment.name }}</td>
@@ -60,7 +60,7 @@ <h1 id="site-name">Comment moderation queue</h1>
60 60
           <td>
61 61
             <img
62 62
               src="{% admin_media_prefix %}img/admin/icon-{% if comment.user %}yes{% else %}no{% endif %}.gif"
63  
-              alt="{% if comment.user %}yes{% else %}no{% endif %}"
  63
+              alt="{% if comment.user %}{% trans "yes" %}{% else %}{% trans "no" %}{% endif %}"
64 64
             />
65 65
           </td>
66 66
           <td>{{ comment.ip_address }}</td>
7  django/contrib/comments/templates/comments/posted.html
... ...
@@ -1,7 +1,8 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Thanks for commenting.{% endblock %}
  4
+{% block title %}{% trans "Thanks for commenting" %}.{% endblock %}
4 5
 
5 6
 {% block content %}
6  
-  <h1>Thank you for your comment.</h1>
7  
-{% endblock %}
  7
+  <h1>{% trans "Thank you for your comment" %}.</h1>
  8
+{% endblock %}
13  django/contrib/comments/templates/comments/preview.html
... ...
@@ -1,17 +1,18 @@
1 1
 {% extends "comments/base.html" %}
  2
+{% load i18n %}
2 3
 
3  
-{% block title %}Preview your comment{% endblock %}
  4
+{% block title %}{% trans "Preview your comment" %}{% endblock %}
4 5
 
5 6
 {% block content %}
6 7
   {% load comments %}
7 8
   <form action="{% comment_form_target %}" method="post">
8 9
     {% if form.errors %}
9  
-      <h1>Please correct the error{{ form.errors|pluralize }} below</h1>
  10
+    <h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1>
10 11
     {% else %}
11  
-      <h1>Preview your comment</h1>
  12
+    <h1>{% trans "Preview your comment" %}</h1>
12 13
       <blockquote>{{ comment|linebreaks }}</blockquote>
13 14
       <p>
14  
-        and <input type="submit" name="submit" value="Post your comment" id="submit" /> or make changes:
  15
+      {% trans "and" %} <input type="submit" name="submit" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
15 16
       </p>
16 17
     {% endif %}
17 18
     {% for field in form %}
@@ -27,8 +28,8 @@
27 28
       {% endif %}
28 29
     {% endfor %}
29 30
     <p class="submit">
30  
-      <input type="submit" name="submit" class="submit-post" value="Post" />
31  
-      <input type="submit" name="submit" class="submit-preview" value="Preview" />
  31
+    <input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
  32
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
32 33
     </p>
33 34
   </form>
34 35
 {% endblock %}
5  django/contrib/comments/views/comments.py
@@ -62,8 +62,7 @@ def post_comment(request, next=None):
62 62
                 (escape(ctype), escape(object_pk)))
63 63
 
64 64
     # Do we want to preview the comment?
65  
-    preview = data.get("submit", "").lower() == "preview" or \
66  
-              data.get("preview", None) is not None
  65
+    preview = "preview" in data
67 66
 
68 67
     # Construct the comment form
69 68
     form = comments.get_form()(target, data=data)
@@ -85,7 +84,7 @@ def post_comment(request, next=None):
85 84
             template_list, {
86 85
                 "comment" : form.data.get("comment", ""),
87 86
                 "form" : form,
88  
-            }, 
  87
+            },
89 88
             RequestContext(request, {})
90 89
         )
91 90
 
2  tests/regressiontests/comment_tests/tests/comment_view_tests.py
@@ -45,7 +45,7 @@ def testPostCommentBadObjectPK(self):
45 45
     def testCommentPreview(self):
46 46
         a = Article.objects.get(pk=1)
47 47
         data = self.getValidData(a)
48  
-        data["submit"] = "preview"
  48
+        data["preview"] = "Preview"
49 49
         response = self.client.post("/post/", data)
50 50
         self.assertEqual(response.status_code, 200)
51 51
         self.assertTemplateUsed(response, "comments/preview.html")

0 notes on commit ccc2387

Please sign in to comment.
Something went wrong with that request. Please try again.