Skip to content

Commit c137adc

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

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

dashboard/models.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
88
from django.contrib.contenttypes.models import ContentType
99
from django.db import connections, models
10+
from django.utils.translation import gettext_lazy as _
1011
from django_hosts.resolvers import reverse
1112

1213
from tracdb.models import Ticket
@@ -15,9 +16,9 @@
1516
METRIC_PERIOD_DAILY = "daily"
1617
METRIC_PERIOD_WEEKLY = "weekly"
1718
METRIC_PERIOD_CHOICES = (
18-
(METRIC_PERIOD_INSTANT, "Instant"),
19-
(METRIC_PERIOD_DAILY, "Daily"),
20-
(METRIC_PERIOD_WEEKLY, "Weekly"),
19+
(METRIC_PERIOD_INSTANT, _("Instant")),
20+
(METRIC_PERIOD_DAILY, _("Daily")),
21+
(METRIC_PERIOD_WEEKLY, _("Weekly")),
2122
)
2223

2324

@@ -26,7 +27,7 @@ class Category(models.Model):
2627
position = models.PositiveSmallIntegerField(default=1)
2728

2829
class Meta:
29-
verbose_name_plural = "categories"
30+
verbose_name_plural = _("categories")
3031

3132
def __str__(self):
3233
return self.name
@@ -94,7 +95,7 @@ def _gather_data_instant(self, since):
9495

9596
def _gather_data_periodic(self, since, period):
9697
"""
97-
Gather data from "periodic" merics.
98+
Gather data from "periodic" metrics.
9899
99100
Period metrics are reset every day/week/month and count up as the period
100101
goes on. Think "commits today" or "new tickets this week".
@@ -183,25 +184,29 @@ class JenkinsFailuresMetric(Metric):
183184
"""
184185

185186
jenkins_root_url = models.URLField(
186-
verbose_name="Jenkins instance root URL",
187+
verbose_name=_("Jenkins instance root URL"),
187188
max_length=1000,
188-
help_text="E.g. http://ci.djangoproject.com/",
189+
help_text=_("E.g. http://ci.djangoproject.com/"),
189190
)
190191
build_name = models.CharField(
191192
max_length=100,
192-
help_text="E.g. Django Python3",
193+
help_text=_("E.g. Django Python3"),
193194
)
194195
is_success_cnt = models.BooleanField(
195196
default=False,
196-
verbose_name="Should the metric be a value representing success ratio?",
197-
help_text="E.g. if there are 50 tests of which 30 are failing the value "
198-
"of this metric will be 20 (or 40%.)",
197+
verbose_name=_("Should the metric be a value representing success ratio?"),
198+
help_text=_(
199+
"E.g. if there are 50 tests of which 30 are failing the value "
200+
"of this metric will be 20 (or 40%.)"
201+
),
199202
)
200203
is_percentage = models.BooleanField(
201204
default=False,
202-
verbose_name="Should the metric be a percentage value?",
203-
help_text="E.g. if there are 50 tests of which 30 are failing the value of "
204-
"this metric will be 60%.",
205+
verbose_name=_("Should the metric be a percentage value?"),
206+
help_text=_(
207+
"E.g. if there are 50 tests of which 30 are failing the value of "
208+
"this metric will be 60%."
209+
),
205210
)
206211

207212
def urljoin(self, *parts):

dashboard/templates/base_dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{% block sectionid %}dashboard{% endblock %}
55

6-
{% block title %}{% trans 'Development dashboard' %}{% endblock %}
6+
{% block title %}{% translate 'Development dashboard' %}{% endblock %}
77
{% block layout_class %}full-width{% endblock %}
88
{% block header %}
99
<h1 class="visuallyhidden">Development dashboard</h1>

dashboard/templates/dashboard/detail.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "base_dashboard.html" %}
2+
{% load i18n %}
23

34
{% block title %}{{ metric }} | {{ block.super }}{% endblock %}
45

@@ -8,6 +9,6 @@ <h2><a href="{{ metric.link }}">{{ metric }}</a></h2>
89
<div class="graph-wrapper">
910
<div id="graph" class="graph" data-path="{% url "metric-list" host "dashboard" %}" data-metric="{{ metric.slug }}"></div>
1011
</div>
11-
<a class="link-readmore back-link" href="{% url "dashboard-index" host "dashboard" %}">All metrics</a>
12+
<a class="link-readmore back-link" href="{% url "dashboard-index" host "dashboard" %}">{% translate "All metrics" %}</a>
1213
</div>
1314
{% endblock %}

dashboard/templates/dashboard/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h3><a href="{{ report.metric.link }}">{{ report.metric.name }}</a></h3>
1919
</div>
2020
{% endfor %}
2121
<p class="updated">
22-
{% blocktrans with timestamp=data.0.latest.timestamp|timesince %}Updated {{ timestamp }} ago.{% endblocktrans %}
22+
{% blocktranslate with timestamp=data.0.latest.timestamp|timesince %}Updated {{ timestamp }} ago.{% endblocktranslate %}
2323
</p>
2424
</div>
2525
{% endblock %}

dashboard/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.forms.models import model_to_dict
66
from django.http.response import Http404, JsonResponse
77
from django.shortcuts import render
8+
from django.utils.translation import gettext as _
89

910
from .models import Metric
1011
from .utils import generation_key
@@ -69,4 +70,4 @@ def _find_metric_or_404(slug):
6970
return MC.objects.get(slug=slug)
7071
except MC.DoesNotExist:
7172
continue
72-
raise Http404(f"Could not find metric with slug {slug}")
73+
raise Http404(_("Could not find metric with slug %s") % slug)

0 commit comments

Comments
 (0)