Skip to content

Commit

Permalink
[dashboard] Marked all user-facing strings for translation
Browse files Browse the repository at this point in the history
Refs #1648
  • Loading branch information
marksweb authored Oct 25, 2024
1 parent 27a40b5 commit c137adc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
33 changes: 19 additions & 14 deletions dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.db import connections, models
from django.utils.translation import gettext_lazy as _
from django_hosts.resolvers import reverse

from tracdb.models import Ticket
Expand All @@ -15,9 +16,9 @@
METRIC_PERIOD_DAILY = "daily"
METRIC_PERIOD_WEEKLY = "weekly"
METRIC_PERIOD_CHOICES = (
(METRIC_PERIOD_INSTANT, "Instant"),
(METRIC_PERIOD_DAILY, "Daily"),
(METRIC_PERIOD_WEEKLY, "Weekly"),
(METRIC_PERIOD_INSTANT, _("Instant")),
(METRIC_PERIOD_DAILY, _("Daily")),
(METRIC_PERIOD_WEEKLY, _("Weekly")),
)


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

class Meta:
verbose_name_plural = "categories"
verbose_name_plural = _("categories")

def __str__(self):
return self.name
Expand Down Expand Up @@ -94,7 +95,7 @@ def _gather_data_instant(self, since):

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

jenkins_root_url = models.URLField(
verbose_name="Jenkins instance root URL",
verbose_name=_("Jenkins instance root URL"),
max_length=1000,
help_text="E.g. http://ci.djangoproject.com/",
help_text=_("E.g. http://ci.djangoproject.com/"),
)
build_name = models.CharField(
max_length=100,
help_text="E.g. Django Python3",
help_text=_("E.g. Django Python3"),
)
is_success_cnt = models.BooleanField(
default=False,
verbose_name="Should the metric be a value representing success ratio?",
help_text="E.g. if there are 50 tests of which 30 are failing the value "
"of this metric will be 20 (or 40%.)",
verbose_name=_("Should the metric be a value representing success ratio?"),
help_text=_(
"E.g. if there are 50 tests of which 30 are failing the value "
"of this metric will be 20 (or 40%.)"
),
)
is_percentage = models.BooleanField(
default=False,
verbose_name="Should the metric be a percentage value?",
help_text="E.g. if there are 50 tests of which 30 are failing the value of "
"this metric will be 60%.",
verbose_name=_("Should the metric be a percentage value?"),
help_text=_(
"E.g. if there are 50 tests of which 30 are failing the value of "
"this metric will be 60%."
),
)

def urljoin(self, *parts):
Expand Down
2 changes: 1 addition & 1 deletion dashboard/templates/base_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% block sectionid %}dashboard{% endblock %}

{% block title %}{% trans 'Development dashboard' %}{% endblock %}
{% block title %}{% translate 'Development dashboard' %}{% endblock %}
{% block layout_class %}full-width{% endblock %}
{% block header %}
<h1 class="visuallyhidden">Development dashboard</h1>
Expand Down
3 changes: 2 additions & 1 deletion dashboard/templates/dashboard/detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "base_dashboard.html" %}
{% load i18n %}

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

Expand All @@ -8,6 +9,6 @@ <h2><a href="{{ metric.link }}">{{ metric }}</a></h2>
<div class="graph-wrapper">
<div id="graph" class="graph" data-path="{% url "metric-list" host "dashboard" %}" data-metric="{{ metric.slug }}"></div>
</div>
<a class="link-readmore back-link" href="{% url "dashboard-index" host "dashboard" %}">All metrics</a>
<a class="link-readmore back-link" href="{% url "dashboard-index" host "dashboard" %}">{% translate "All metrics" %}</a>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion dashboard/templates/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h3><a href="{{ report.metric.link }}">{{ report.metric.name }}</a></h3>
</div>
{% endfor %}
<p class="updated">
{% blocktrans with timestamp=data.0.latest.timestamp|timesince %}Updated {{ timestamp }} ago.{% endblocktrans %}
{% blocktranslate with timestamp=data.0.latest.timestamp|timesince %}Updated {{ timestamp }} ago.{% endblocktranslate %}
</p>
</div>
{% endblock %}
3 changes: 2 additions & 1 deletion dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.forms.models import model_to_dict
from django.http.response import Http404, JsonResponse
from django.shortcuts import render
from django.utils.translation import gettext as _

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

0 comments on commit c137adc

Please sign in to comment.