Skip to content

Commit 27a40b5

Browse files
authored
[aggregator] Marked all user-facing strings for translation
Refs #1648
1 parent a03e6fa commit 27a40b5

File tree

11 files changed

+90
-66
lines changed

11 files changed

+90
-66
lines changed

aggregator/feeds.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.contrib.syndication.views import Feed
22
from django.shortcuts import get_object_or_404
3+
from django.utils.translation import gettext_lazy as _
34
from django_hosts.resolvers import reverse
45

56
from .models import FeedItem, FeedType
@@ -42,7 +43,7 @@ def items(self, obj):
4243
return qs[:25]
4344

4445
def title(self, obj):
45-
return "Django community aggregator: %s" % obj.name
46+
return _("Django community aggregator: %s") % obj.name
4647

4748
def link(self, obj):
4849
return reverse("aggregator-feed", args=[obj.slug], host="www")
@@ -52,8 +53,8 @@ def description(self, obj):
5253

5354

5455
class CommunityAggregatorFirehoseFeed(BaseCommunityAggregatorFeed):
55-
title = "Django community aggregator firehose"
56-
description = "All activity from the Django community aggregator"
56+
title = _("Django community aggregator firehose")
57+
description = _("All activity from the Django community aggregator")
5758

5859
def link(self):
5960
return reverse("aggregator-firehose-feed", host="www")

aggregator/forms.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django import forms
2+
from django.utils.translation import gettext_lazy as _
23

34
from .models import Feed
45

@@ -9,7 +10,7 @@ class FeedModelForm(forms.ModelForm):
910
widget=forms.TextInput(
1011
attrs={
1112
"class": "required",
12-
"placeholder": "Title of the resource / blog",
13+
"placeholder": _("Title of the resource / blog"),
1314
}
1415
),
1516
)
@@ -18,7 +19,7 @@ class FeedModelForm(forms.ModelForm):
1819
widget=forms.TextInput(
1920
attrs={
2021
"class": "required",
21-
"placeholder": (
22+
"placeholder": _(
2223
"Link to the RSS/Atom feed. Please only use "
2324
"Django-specific feeds."
2425
),
@@ -30,7 +31,7 @@ class FeedModelForm(forms.ModelForm):
3031
widget=forms.TextInput(
3132
attrs={
3233
"class": "required",
33-
"placeholder": "Link to main page (i.e. blog homepage)",
34+
"placeholder": _("Link to main page (i.e. blog homepage)"),
3435
}
3536
),
3637
)
@@ -43,7 +44,9 @@ def clean_feed_url(self):
4344
feed_url = self.cleaned_data.get("feed_url")
4445
if feed_url and "//stackoverflow.com" in feed_url:
4546
raise forms.ValidationError(
46-
"Stack Overflow questions tagged with 'django' will appear "
47-
"here automatically."
47+
_(
48+
"Stack Overflow questions tagged with 'django' will appear "
49+
"here automatically."
50+
)
4851
)
4952
return feed_url

aggregator/models.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.contrib.auth.models import User
77
from django.core.exceptions import ValidationError
88
from django.db import models
9+
from django.utils.translation import gettext_lazy as _
910
from django_countries.fields import CountryField
1011
from django_push.subscriber import signals as push_signals
1112
from django_push.subscriber.models import Subscription
@@ -34,9 +35,9 @@ def items(self):
3435
PENDING_FEED = "P"
3536

3637
STATUS_CHOICES = (
37-
(PENDING_FEED, "Pending"),
38-
(DENIED_FEED, "Denied"),
39-
(APPROVED_FEED, "Approved"),
38+
(PENDING_FEED, _("Pending")),
39+
(DENIED_FEED, _("Denied")),
40+
(APPROVED_FEED, _("Approved")),
4041
)
4142

4243

@@ -200,13 +201,13 @@ def feed_updated(sender, notification, **kwargs):
200201
push_signals.updated.connect(feed_updated)
201202

202203
CONTINENTS = [
203-
("Africa", "Africa"),
204-
("North America", "North America"),
205-
("South America", "South America"),
206-
("Europe", "Europe"),
207-
("Asia", "Asia"),
208-
("Oceania", "Oceania"),
209-
("Antarctica", "Antarctica"),
204+
("Africa", _("Africa")),
205+
("North America", _("North America")),
206+
("South America", _("South America")),
207+
("Europe", _("Europe")),
208+
("Asia", _("Asia")),
209+
("Oceania", _("Oceania")),
210+
("Antarctica", _("Antarctica")),
210211
]
211212

212213

aggregator/views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.contrib import messages
22
from django.contrib.auth.decorators import login_required
33
from django.shortcuts import get_object_or_404, redirect, render
4+
from django.utils.translation import gettext as _
45
from django.views.generic.list import ListView
56

67
from .forms import FeedModelForm
@@ -70,8 +71,10 @@ def add_feed(request, feed_type_slug):
7071
messages.add_message(
7172
request,
7273
messages.INFO,
73-
"Your feed has entered moderation. "
74-
"Please allow up to 1 week for processing.",
74+
_(
75+
"Your feed has entered moderation. "
76+
"Please allow up to 1 week for processing."
77+
),
7578
)
7679
return redirect("community-index")
7780

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{% extends "base_community.html" %}
2+
{% load i18n %}
23

34
{% block content %}
4-
<h1>Community</h1>
5+
<h1>{% translate "Community" %}</h1>
56

6-
<h2 class="deck">Really delete {{ feed }}?</h2>
7+
<h2 class="deck">{% blocktranslate %}Really delete {{ feed }}?{% endblocktranslate %}</h2>
78

89
<p>
9-
We haven't implemented an undo feature yet, so all items will be deleted immediately.
10+
{% blocktranslate trimmed %}
11+
We haven't implemented an undo feature yet, so all items will be deleted immediately.
12+
{% endblocktranslate %}
1013
</p>
1114

1215
<form class="wide" action="." method="post">
1316
{% csrf_token %}
14-
<p class="submit"><input class="cta" type="submit" value="Yes, delete the feed."></p>
17+
<p class="submit"><input class="cta" type="submit" value="{% translate "Yes, delete the feed." %}"></p>
1518
</form>
1619
{% endblock %}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{% extends "base_community.html" %}
2+
{% load i18n %}
23

34
{% block content %}
4-
<h1>Community</h1>
5+
<h1>{% translate "Community" %}</h1>
56

6-
<h2>Sorry, you can't do that.</h2>
7+
<h2>{% translate "Sorry, you can't do that." %}</h2>
78
{% endblock %}

djangoproject/templates/aggregator/edit-feed.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{% extends "base_community.html" %}
2+
{% load i18n %}
23

34
{% block content %}
4-
<h1>Community</h1>
5+
<h1>{% translate "Community" %}</h1>
56

67
{% if adding %}
7-
<h2 class="deck">Add a {{ feed_type }} feed:</h2>
8+
<h2 class="deck">{% blocktranslate with type=feed_type %}Add a {{ type }} feed:{% endblocktranslate %}</h2>
89
{% else %}
9-
<h2 class="deck">Edit {{ feed }}:</h2>
10+
<h2 class="deck">{% blocktranslate %}Edit {{ feed }}:{% endblocktranslate %}</h2>
1011
{% endif %}
1112

1213
<form method="POST" action="" id="add_feed_form" class="wide form-input">
@@ -20,9 +21,9 @@ <h2 class="deck">Edit {{ feed }}:</h2>
2021
</p>
2122
{% endfor %}
2223
{% if adding %}
23-
<p class="submit"><input class="cta" type="submit" value="Add Feed"></p>
24+
<p class="submit"><input class="cta" type="submit" value="{% translate "Add Feed" %}"></p>
2425
{% else %}
25-
<p class="submit"><input class="cta" type="submit" value="Save"></p>
26+
<p class="submit"><input class="cta" type="submit" value="{% translate "Save" %}"></p>
2627
{% endif %}
2728
</form>
2829

djangoproject/templates/aggregator/feeditem_list.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
{% extends "base_community.html" %}
2+
{% load i18n %}
23

34
{% block content %}
4-
<h1>Django community: {{ feed_type.name }}
5-
<a class="rss" href="{% url 'aggregator-feed' feed_type.slug %}">RSS</a></h1>
6-
<h2 class="deck">
7-
This page, updated regularly, aggregates {{ feed_type.name }}
8-
from the Django community.
5+
{% url 'aggregator-feed' feed_type.slug as feed_url %}
6+
<h1>{% blocktranslate trimmed with name=feed_type.name %}Django community: {{ feed_type.name }}
7+
<a class="rss" href="{{ feed_url }}">RSS</a>{% endblocktranslate %}</h1>
8+
<h2 class="deck">{% blocktranslate trimmed with name=feed_type.name %}
9+
This page, updated regularly, aggregates {{ name }}
10+
from the Django community.{% endblocktranslate %}
911
</h2>
1012

1113
<ul class="list-news">
1214
{% for item in object_list %}
1315
<li>
1416
<h2><a href="{{ item.link }}">{{ item.title }}</a></h2>
15-
<span class='meta'>Posted on {{ item.date_modified|date:"F j, Y" }} at {{ item.date_modified|date:"g:i A" }} by <a href="{{ item.feed.public_url }}">{{ item.feed.title }}</a> <a class="rss" href="{{ item.feed.feed_url }}">RSS</a></span>
17+
<span class='meta'>{% blocktranslate trimmed with date_modified=item.date_modified|date:"DATE_FORMAT" time_modified=item.date_modified|date:"TIME_FORMAT" public_url=item.feed.public_url title=item.feed.title feed_url=item.feed.feed_url %}
18+
Posted on {{ date_modified }} at {{ time_modified }} by <a href="{{ public_url }}">{{ title }}</a> <a class="rss" href="{{ feed_url }}">RSS</a>
19+
{% endblocktranslate %}</span>
1620
<div>
1721
{{ item.summary|striptags|truncatewords:"200" }}
1822
</div>
19-
<p class="small"><a class="link-readmore" href="{{ item.link }}">Read this post in context</a></p>
23+
<p class="small"><a class="link-readmore" href="{{ item.link }}">{% translate "Read this post in context" %}</a></p>
2024
</li>
2125
{% endfor %}
2226
</ul>
@@ -27,13 +31,13 @@ <h2><a href="{{ item.link }}">{{ item.title }}</a></h2>
2731
{% if page_obj.has_previous %}
2832
<li><a class="previous" href="?page={{ page_obj.previous_page_number }}">
2933
<i class="icon icon-chevron-left"></i>
30-
<span class="visuallyhidden">Previous</span>
34+
<span class="visuallyhidden">{% translate "Previous" context "pagination" %}</span>
3135
</a></li>
3236
{% endif %}
3337
{% if page_obj.has_next %}
3438
<li><a class="next" href="?page={{ page_obj.next_page_number }}">
3539
<i class="icon icon-chevron-right"></i>
36-
<span class="visuallyhidden">Next</span>
40+
<span class="visuallyhidden">{% translate "Next" context "pagination" %}</span>
3741
</a></li>
3842
{% endif %}
3943
</ul>
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,59 @@
11
{% extends "base_community.html" %}
2+
{% load i18n %}
23

34
{% block layout_class %}column-container sidebar-right{% endblock %}
45

56
{% block content %}
67

7-
<h2 class="community-title">Get Help</h2>
8+
<h2 class="community-title">{% translate "Get Help" %}</h2>
89
<div class="community-cta-wrapper">
910
<a href="https://forum.djangoproject.com/" class="community-cta-a">
1011
<div class="community-cta">
1112
<div>
1213
{% include "svg_logos/forum.html" %}
1314
</div>
14-
<h3>Forum - Post a question</h3>
15+
<h3>{% translate "Forum - Post a question" %}</h3>
1516
</div>
1617
</a>
1718
<a href="https://discord.gg/xcRH6mN4fa" class="community-cta-a">
1819
<div class="community-cta">
1920
<div>
2021
{% include "svg_logos/discord.html" %}
2122
</div>
22-
<h3>Discord - Chat with us</h3>
23+
<h3>{% translate "Discord - Chat with us" %}</h3>
2324
</div>
2425
</a>
2526
</div>
2627

27-
<h2 class="community-title">Get Involved</h2>
28+
<h2 class="community-title">{% translate "Get Involved" %}</h2>
2829
<div class="community-cta-wrapper">
2930
<a href="https://docs.djangoproject.com/en/dev/internals/contributing/bugs-and-features/#reporting-bugs" class="community-cta-a">
3031
<div class="community-cta">
3132
<div>
3233
{% include "svg_logos/bug.html" %}
3334
</div>
34-
<h3>Report an issue</h3>
35+
<h3>{% translate "Report an issue" %}</h3>
3536
</div>
3637
</a>
3738
<a href="https://docs.djangoproject.com/en/dev/internals/contributing/" class="community-cta-a">
3839
<div class="community-cta">
3940
<div>
4041
{% include "svg_logos/notepad.html" %}
4142
</div>
42-
<h3>Contribute to Django</h3>
43+
<h3>{% translate "Contribute to Django" %}</h3>
4344
</div>
4445
</a>
4546
<a href="/community/local/" class="community-cta-a">
4647
<div class="community-cta">
4748
<div>
4849
{% include "svg_logos/world.html" %}
4950
</div>
50-
<h3>Local Django Community</h3>
51+
<h3>{% translate "Local Django Community" %}</h3>
5152
</div>
5253
</a>
5354
</div>
5455

55-
<h2>Django RSS feeds</h2>
56+
<h2>{% translate "Django RSS feeds" %}</h2>
5657
<ul class="list-collapsing">
5758
{% for feedtype, latest_feeds in feedtype_list %}
5859
<li id="{{ feedtype.slug }}">
@@ -61,26 +62,30 @@ <h2 class="bullet-icon"><i class="icon icon-rss blue"></i> {{ feedtype.name }}</
6162
<dl class="list-links">
6263
{% for item in latest_feeds %}
6364
<dt><a href="{{ item.link }}">{{ item.title }}</a></dt>
64-
<dd>{{ item.date_modified|date:"N jS, Y \a\t P" }} by <a href="{{ item.feed.public_url }}">{{ item.feed.title }}</a></dd>
65+
<dd>
66+
{% blocktranslate trimmed with modified_date=item.date_modified|date:"DATETIME_FORMAT" public_url=item.feed.public_url title=item.feed.title %}
67+
{{ modified_date }} by <a href="{{ public_url }}">{{ title }}</a>
68+
{% endblocktranslate %}
69+
</dd>
6570
{% endfor %}
6671
</dl>
6772
<p class="meta">
6873
{% if latest_feeds %}
69-
<a href="{% url 'community-feed-list' feedtype.slug %}">View more</a>
74+
<a href="{% url 'community-feed-list' feedtype.slug %}">{% translate "View more" %}</a>
7075
{% endif %}
7176
{% if latest_feeds and feedtype.can_self_add %}
72-
or
77+
{% translate "or" context "view more OR add your feed" %}
7378
{% endif %}
7479
{% if feedtype.can_self_add %}
75-
<a href="{% url 'community-add-feed' feedtype.slug %}">Add your feed</a>
80+
<a href="{% url 'community-add-feed' feedtype.slug %}">{% translate "Add your feed" %}</a>
7681
{% endif %}
7782
</p>
7883
</div>
7984
</li>
8085
{% endfor %}
8186
</ul>
8287

83-
<h2>Mailing Lists</h2>
88+
<h2>{% translate "Mailing Lists" %}</h2>
8489
{% include "includes/mailing_lists.html" %}
8590

8691
{% endblock %}

0 commit comments

Comments
 (0)