Skip to content

Commit

Permalink
Fix tags inside {% trans %} tags
Browse files Browse the repository at this point in the history
  • Loading branch information
yourcelf committed Oct 21, 2014
1 parent c0b2c8d commit 19ec4cd
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 24 deletions.
10 changes: 9 additions & 1 deletion scanblog/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@

* replace &#9997 by css class and css display

* optionnal sharing buttons
* optional sharing buttons

* Replace atomic translations with blocktrans in the following:
- scanblog/templates/blogs/_sharing_buttons.html
- scanblog/templates/blogs/all_comments_list.html
- scanblog/templates/blogs/delete_post.html
- scanblog/templates/blogs/tag_post_list.html
- scanblog/templates/btb/admin-content-flagged.txt
- scanblog/templates/comments/unremove_comment.html
6 changes: 5 additions & 1 deletion scanblog/templates/about/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
{% block title %}{% trans "Terms of Use" %}{% endblock %}
{% block body %}
<div class='terms'>
<h2>{% trans "{{ site.name }} Terms of Use" %}</h2>
<h2>
{% blocktrans with site_name=site.name %}
Terms of Use

This comment has been minimized.

Copy link
@arthurlutz

arthurlutz Oct 21, 2014

Contributor

I think this is missing a {{ site_name }}

This comment has been minimized.

Copy link
@yourcelf

yourcelf Oct 22, 2014

Author Owner

indeed, thanks. Just pushed a commit to fix.

{% endblocktrans %}
</h2>
<p><b>
{% blocktrans %}
PLEASE REVIEW BEFORE USING THIS WEBSITE &ndash; IF YOU DO NOT AGREE TO THESE TERMS OF USE, DO NOT USE THIS WEBSITE.
Expand Down
5 changes: 4 additions & 1 deletion scanblog/templates/blogs/page_picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
}
</style>
<noscript>
{% trans "This page requires javascript. To browse {{ site.name }} without javascript, try" %} <a href='{% url "blogs.home" %}'>{% trans "blogs" %}</a>.
{% url "blogs.home" as blogs_home_url %}
{% blocktrans with site_name=site.name %}
This page requires javascript. To browse {{ site_name }} without javascript, try <a href='{{ blogs_home_url }}'>the main blogs page</a>.
{% endblocktrans %}
</noscript>
<h1>{% trans "Every page" %}</h1>
<div id='pagepicker'></div>
Expand Down
6 changes: 4 additions & 2 deletions scanblog/templates/blogs/post_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
{% load favorites %}

<!-- don't know how to trans 'Untitled' FIXME -->
{% block title %}{% firstof post.title "Untitled" %} &mdash; {{post.author.profile}}{% endblock %}
{% trans "Untitled" as untitled_i18n %}
{% block title %}{% firstof post.title untitled_i18n %} &mdash; {{post.author.profile}}{% endblock %}

{% block head %}
{% with feed_author=post.author comment_feed_obj=post %}
Expand All @@ -33,7 +34,8 @@
{% endif %}
{% trans "by" %} <a href='{{post.author.profile.get_blog_url}}'>{{ post.author.profile.display_name }}</a>
{% if post.author.profile.has_public_profile %}
({% trans "author's <a href='{{ post.author.profile.get_absolute_url }}'>profile</a>" %})
{% blocktrans with profile_url=post.author.profile.get_absolute_url %}
(author's <a href='{{ profile_url }}'>profile</a>)
{% endif %}
{% if org.public %}, {% trans "writing for" %} <em><a href='{{ org.get_absolute_url }}'>{{ org.name }}</a></em>{% endif %}
{% if org.public %}{{ org.footer|safe }}{% endif %}
Expand Down
6 changes: 5 additions & 1 deletion scanblog/templates/btb/org_status_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
</style>
</head>
<body>
<h1>{% trans "The State of the {{ org.name }} is" %} <em>{{ adjective.word }}</em></h1>
<h1>
{% blocktrans with org_name=org.name adjective_word=adjective.word %}
The State of the {{ org_name }} is <em>{{ adjective_word }}</em>
{% endblocktrans %}
</h1>
<span style='font-size: 8px'><b>{{ adjective.word }}</b>: <i>{{ adjective.definition }}</i></span>
<h2>{% trans "Distance from inbox zero:" %} {{ inbox_zero_distance }}.</h2>
{% if inbox_zero_distance == 0 %}
Expand Down
7 changes: 5 additions & 2 deletions scanblog/templates/comments/_comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
</td>
<td>
<span class='comment-date'>
{% trans "Posted {{ comment.created|timesince }} ago." %}
{% blocktrans with time_since_created=comment.created|timesince %}
Posted {{ time_since_created }} ago.
{% endblocktrans %}
</span>
{% if comment.letter_sent and not comment.removed %}
<span class='comment-date-mailed'>
&check;
{% trans "Mailed {{ comment.letter_sent|timesince }} ago" %}
{% blocktrans with time_since_sent=comment.letter_sent|timesince %}
Mailed {{ time_since_sent }} ago
</span>
{% endif %}
</td>
Expand Down
13 changes: 8 additions & 5 deletions scanblog/templates/comments/remove_comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
<h1>{% trans "Remove Comment" %}</h1>
{% if removal.pk %}
<p>
<b>{% trans "This comment has been removed." %}</b> {% trans "You can edit the messages that haven't been sent below.
Changed your mind?" %} <a href='{% url "comments.moderator_unremove" comment.pk %}'>{% trans "Restore (unremove) this comment" %}</a>.
<b>{% trans "This comment has been removed." %}</b>
{% trans "You can edit the messages that haven't been sent below. Changed your mind?" %} <a href='{% url "comments.moderator_unremove" comment.pk %}'>{% trans "Restore (unremove) this comment" %}</a>.
</p>
{% else %}
<p>{% trans "Remove the following comment by <em>{{ comment.user.profile }}</em>? (If this is spam, use <a href='{% url "comments.spam_can_comment" comment.pk %}'>this form</a> instead)" %}</p>
<p>
{% url "comments.spam_can_comment" comment.pk as spam_comment_url %}
{% blocktrans with commenter=comment.user.profile %}
Remove the following comment by <em>{{ commenter }}</em>? (If this is spam, use <a href='{{ spam_comment_url }}'>this form</a> instead)</p>
{% endblocktrans %}
{% endif %}

<p>posted <a href='{{ comment.get_absolute_url }}'>{{ comment.created|date }}</a> on
Expand Down Expand Up @@ -107,8 +111,7 @@ <h2>{% firstof form.post_author_message.label "Post author message" %}</h2>
{% if form.post_author_message.errors %}
<div class='error'>
<h3>
{% trans "There was an error with the message body below; we couldn't
compile it into a letter." %}
{% trans "There was an error with the message body below; we couldn't compile it into a letter." %}
</h3>
<p>{% trans "The cryptic error message we got was:" %}</p>
<pre>{{ form.post_author_message.errors }}</pre>
Expand Down
6 changes: 5 additions & 1 deletion scanblog/templates/comments/unremove_comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
{% block body %}
<h1>{% trans "Unremove Comment" %}</h1>

<p>{% trans "Restore the following comment, which was removed on {{ removal.date|date }}?" %}</p>
<p>
{% blocktrans with removal_date=removal.date|date %}
Restore the following comment, which was removed on {{ removal_date }}?
{% endblocktrans %}
</p>

<p>posted <a href='{{ comment.get_absolute_url }}'>{{ comment.created|date }}</a> on
<a href='{{ comment.document.get_absolute_url }}'>{{ comment.document.get_title }}</a> by
Expand Down
8 changes: 8 additions & 0 deletions scanblog/templates/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

for root, dirs, files in os.walk(os.path.abspath(os.path.dirname(__file__))):
for fn in files:
if fn.endswith(".swp"):
continue
path = os.path.join(root, fn)
with open(path) as fh:
txt = fh.read()
Expand Down Expand Up @@ -31,3 +33,9 @@
# Look for tabs
if "\t" in txt:
print "has tab characters", path

# Look for blocks and variables inside {% trans "" %} tags
for match in re.finditer(r"""\{\% trans ((.(?!\%\}))*) \%\}""", txt):
if re.search("[\{\}]+", match.group(1)):
print "tags in trans", path

4 changes: 3 additions & 1 deletion scanblog/templates/notification/notice_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ <h2>{% trans "Subscriptions" %}</h2>
{% trans "Posts from the" %} <em><a href='{{ sub.campaign.get_absolute_url }}'>{{ sub.campaign.title }}</a></em> campaign
{% endif %}
{% if sub.affiliation_id %}
{% trans "Posts from the <em><a href='{{ sub.campaign.get_absolute_url }}'>{{ sub.campaign.title }}</a></em> campaign" %}
{% blocktrans with campaign_url=sub.campaign.get_absolute_url campaign_title=sub.campaign.title %}
Posts from the <em><a href='{{ campaign_url }}'>{{ campaign_title }}</a></em> campaign
{% endblocktrans %}
{% endif %}
</td>
</tr>
Expand Down
17 changes: 9 additions & 8 deletions scanblog/templates/registration/activation_email.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{% load i18n %}
{% trans "Hello" %},
{% blocktrans with site_name=site.name %}
Hello,

{% trans "Welcome to {{ site.name }}! You've just joined a community of respectful
people who value helping to give a voice to the voiceless." %}
Welcome to {{ site_name }}! You've just joined a community of respectful
people who value helping to give a voice to the voiceless.

{% trans "To complete your registration, follow this link:" %}
To complete your registration, follow this link:
{{ base_url }}/accounts/activate/{{ activation_key }}/

{% trans "This link will expire in {{ expiration_days }} days, so don't delay." %}
This link will expire in {{ expiration_days }} days, so don't delay.

{% trans "See you on {{ site.name }}! "%}
See you on {{ site_name }}!

{% trans "Sincerely" %},
Sincerely,

{% trans "{{ site.name }} staff" %}
{{ site.name }} staff
{{ base_url }}
6 changes: 5 additions & 1 deletion scanblog/templates/scanning/flag.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
{% block title %}Flag document{% endblock %}
{% block body %}
<h1>{% trans "Flag content" %}</h1>
<p>{% trans "A flag lets moderators now that something is not right about a particular post, profile, or comment. Please help us by flagging any posts that seem to be against our <a href='{{ about.guidelines }}'>guidelines</a>, or have been improperly edited (for example, pages not rotated correctly)." %}
<p>
{% url "about.guidelines" as about_guidelines_url %}
{% blocktrans %}
A flag lets moderators now that something is not right about a particular post, profile, or comment. Please help us by flagging any posts that seem to be against our <a href='{{ about_guidelines }}'>guidelines</a>, or have been improperly edited (for example, pages not rotated correctly).
{% endblocktrans %}
</p>
<form method='post' action=''>{% csrf_token %}
<table class='form'>
Expand Down

0 comments on commit 19ec4cd

Please sign in to comment.