Skip to content

Commit c6cf32b

Browse files
devGregAclaude
andcommitted
feat(i18n): mark hardcoded template attributes for translation
Wraps 628 literal title/alt/placeholder/data-placeholder/aria-label attribute values across 169 templates (both the v3 and classic UIs) in {% trans %}, adding {% load i18n %} where a template lacked it. Conservative scripted pass: only pure string literals (no nested template tags, no apostrophes) are wrapped; 6 false positives where a {% with %} variable named 'placeholder' matched were reverted. Verified: all 456 templates compile via the Django engine (0 errors) and the findings list (which uses the touched filter_snippet) renders. English output is unchanged since an untranslated msgid renders as its source string. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 34438e7 commit c6cf32b

169 files changed

Lines changed: 735 additions & 607 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dojo/templates/base.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@
144144
<div class="flex items-center h-[var(--dd-topbar-height)] px-4 bg-dd-primary-900 flex-shrink-0">
145145
{% block header_logo %}
146146
<a href="{% url 'home' %}" class="flex items-center gap-2 min-w-0">
147-
<img src="{% static "dojo/img/favicon.png" %}" alt="DefectDojo" class="w-8 h-8 flex-shrink-0">
147+
<img src="{% static "dojo/img/favicon.png" %}" alt="{% trans 'DefectDojo' %}" class="w-8 h-8 flex-shrink-0">
148148
<span class="text-lg font-semibold text-white truncate">DefectDojo</span>
149149
</a>
150150
{% endblock %}
151151
</div>
152152

153153
<!-- Nav items -->
154-
<nav class="flex-1 py-3 space-y-0.5" aria-label="Main navigation">
154+
<nav class="flex-1 py-3 space-y-0.5" aria-label="{% trans 'Main navigation' %}">
155155
{% block sidebar-items %}
156156
<!-- Dashboard -->
157157
<a href="{% url 'dashboard' %}" class="flex items-center gap-3 px-4 py-2 text-gray-300 hover:text-white hover:bg-white/10 transition-colors">
@@ -401,8 +401,8 @@
401401
<div class="flex">
402402
<input id="simple_search" type="text" name="query" value="{{ clean_query }}"
403403
class="flex-1 rounded-l-md border border-r-0 border-gray-300 px-3 py-1.5 text-sm focus:border-dd-primary-400 focus:ring-dd-primary-400"
404-
placeholder="{% trans "Search" %}..." aria-label="Search">
405-
<button type="submit" class="btn btn-primary rounded-l-none" aria-label="Search">
404+
placeholder="{% trans "Search" %}..." aria-label="{% trans 'Search' %}">
405+
<button type="submit" class="btn btn-primary rounded-l-none" aria-label="{% trans 'Search' %}">
406406
<i class="fa-solid fa-magnifying-glass"></i>
407407
</button>
408408
</div>
@@ -444,7 +444,7 @@
444444
<button @click="userOpen = !userOpen"
445445
:aria-expanded="userOpen" aria-controls="user-dropdown"
446446
class="flex items-center gap-1 p-2 text-gray-500 hover:text-gray-700 transition-colors"
447-
aria-label="User Menu">
447+
aria-label="{% trans 'User Menu' %}">
448448
<i class="fa-solid fa-user"></i>
449449
<i class="fa-solid fa-caret-down text-xs"></i>
450450
</button>
@@ -493,7 +493,7 @@
493493
{% if request.user.is_authenticated and announcement %}
494494
<div role="alert" class="announcement-banner alert alert-{{ announcement.style }} {% if announcement.dismissable %}alert-dismissible{% endif %} show">
495495
{% if announcement.dismissable %}
496-
<a href="{% url 'dismiss_announcement' %}" class="close" aria-label="Close">
496+
<a href="{% url 'dismiss_announcement' %}" class="close" aria-label="{% trans 'Close' %}">
497497
<span aria-hidden="true">&times;</span>
498498
</a>
499499
{% endif %}
@@ -507,7 +507,7 @@
507507
<form method="post" action="{% url 'dismiss_os_message' %}" class="os-message-dismiss-form">
508508
{% csrf_token %}
509509
<input type="hidden" name="token" value="{{ banner.dismiss_token }}">
510-
<button type="submit" class="os-message-dismiss" aria-label="Dismiss" title="Dismiss this message">&times;</button>
510+
<button type="submit" class="os-message-dismiss" aria-label="{% trans 'Dismiss' %}" title="{% trans 'Dismiss this message' %}">&times;</button>
511511
</form>
512512
{% endif %}
513513
{{ banner.message|safe }}{% if banner.url %} <a href="{{ banner.url }}">{{ banner.link_text }}</a>{% endif %}
@@ -886,7 +886,7 @@ <h3 class="no-margin-top" style="padding-bottom: 5px;">
886886
{% for message in messages %}
887887
<div class="alert {{ message.tags }} alert-dismissible" role="alert"
888888
x-data="{ show: true }" x-show="show" x-transition>
889-
<button type="button" class="close" @click="show = false" aria-label="Close">
889+
<button type="button" class="close" @click="show = false" aria-label="{% trans 'Close' %}">
890890
<span aria-hidden="true">&times;</span>
891891
</button>
892892
{{ message }}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load i18n %}
12
{% if surveys %}
2-
<a title="Add Questionnaire" class="pull-right btn btn-sm btn-primary" href="/engagement/{{eng.id}}/add_questionnaire"><span class="fa-solid fa-plus"></span></a>
3+
<a title="{% trans 'Add Questionnaire' %}" class="pull-right btn btn-sm btn-primary" href="/engagement/{{eng.id}}/add_questionnaire"><span class="fa-solid fa-plus"></span></a>
34
{% endif %}

dojo/templates/defectDojo-engagement-survey/list_questions.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "base.html" %}
2+
{% load i18n %}
23
{% load display_tags %}
34
{% load authorization_tags %}
45
{% load event_tags %}

dojo/templates/defectDojo-engagement-survey/list_surveys.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "base.html" %}
2+
{% load i18n %}
23
{% load authorization_tags %}
34
{% load event_tags %}
45
{% block content %}
@@ -48,7 +49,7 @@
4849
<div class="panel-heading">
4950
General Questionnaires
5051
{% if "dojo.add_engagement_survey"|has_configuration_permission:request %}
51-
<a title="Add Questionnaire" class="pull-right btn btn-sm btn-primary" href="/empty_questionnaire"><span class="fa-solid fa-plus"></span></a>
52+
<a title="{% trans 'Add Questionnaire' %}" class="pull-right btn btn-sm btn-primary" href="/empty_questionnaire"><span class="fa-solid fa-plus"></span></a>
5253
{% endif %}
5354
</div>
5455
<div class="panel-body">
@@ -129,7 +130,7 @@
129130
<dialog class="modal" id="shareQuestionnaireModal" aria-labelledby="shareQuestionnaireModalLabel">
130131
<div class="modal-content">
131132
<div class="modal-header">
132-
<button type="button" class="close" onclick="this.closest('dialog').close()" aria-label="Close"><span
133+
<button type="button" class="close" onclick="this.closest('dialog').close()" aria-label="{% trans 'Close' %}"><span
133134
aria-hidden="true">&times;</span></button>
134135
<h4 class="modal-title" id="shareQuestionnaireModalLabel">Share Questionnaire Link</h4>
135136
</div>

dojo/templates/dojo/add_note_type.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{% extends "base.html" %}
2+
{% load i18n %}
23
{% block content %}
34
{{ block.super }}
45
<h3> Add a new Note Type </h3>
56
<form class="" action="{% url 'add_note_type' %}" method="post">{% csrf_token %}
67
{% include "dojo/form_fields.html" with form=form %}
78
<div class="form-group">
89
<div class="col-sm-offset-2 col-sm-10">
9-
<input class="btn btn-primary" type="submit" value="Submit" aria-label="Add Note Type"/>
10+
<input class="btn btn-primary" type="submit" value="Submit" aria-label="{% trans 'Add Note Type' %}"/>
1011
</div>
1112
</div>
1213
</form>

dojo/templates/dojo/announcement.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{% extends "base.html" %}
2+
{% load i18n %}
23
{% block content %}
34
{{ block.super }}
45
<form class="" action="{% url 'configure_announcement' %}" method="post" enctype="multipart/form-data">{% csrf_token %}
56
{% include "dojo/form_fields.html" with form=form %}
67
<div class="form-group">
78
<div class="col-sm-offset-2 col-sm-10">
89
{% if remove %}
9-
<input aria-label="Remove" class="btn btn-danger" type="submit" name="_Remove" value="Remove"/>
10+
<input aria-label="{% trans 'Remove' %}" class="btn btn-danger" type="submit" name="_Remove" value="Remove"/>
1011
{% else %}
11-
<input aria-label="Create" class="btn btn-primary" type="submit" name="_Create" value="Create"/>
12+
<input aria-label="{% trans 'Create' %}" class="btn btn-primary" type="submit" name="_Create" value="Create"/>
1213
{% endif %}
1314
</div>
1415
</div>

dojo/templates/dojo/apply_finding_template_form_fields.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load i18n %}
12
{% load as_json %}
23
{% load event_tags %}
34
{% load get_attribute %}
@@ -9,7 +10,7 @@
910
{% endblock %}
1011
{% if form.non_field_errors %}
1112
<div class="alert alert-danger alert-dismissible" role="alert" x-data="{ show: true }" x-show="show" x-transition>
12-
<button type="button" class="close" @click="show = false" aria-label="Close"><span
13+
<button type="button" class="close" @click="show = false" aria-label="{% trans 'Close' %}"><span
1314
aria-hidden="true">&times;</span></button>
1415
{{ form.non_field_errors }}
1516
</div>

dojo/templates/dojo/banner.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{% extends "base.html" %}
2+
{% load i18n %}
23
{% block content %}
34
{{ block.super }}
45
<form class="" action="{% url 'configure_banner' %}" method="post" enctype="multipart/form-data">{% csrf_token %}
56
{% include "dojo/form_fields.html" with form=form %}
67
<div class="form-group">
78
<div class="col-sm-offset-2 col-sm-10">
8-
<input aria-label="Update" class="btn btn-primary" name="update" type="submit" value="Submit"/>
9+
<input aria-label="{% trans 'Update' %}" class="btn btn-primary" name="update" type="submit" value="Submit"/>
910
</div>
1011
</div>
1112
</form>

dojo/templates/dojo/benchmark.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h4>{{ benchmark_type.name }} {{ benchmark_type.version }} - <span id="head__des
2929
data-content="{% trans "Publish will display the ASVS Level on the product and other areas in DefectDojo. Check this once you have completed the assessment." %}"></span>
3030
</label>
3131
{{ benchmark_summary_form.publish }}
32-
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" aria-expanded="false" data-toggle="dropdown" aria-label="Filter options">
32+
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" aria-expanded="false" data-toggle="dropdown" aria-label="{% trans 'Filter options' %}">
3333
<i class="fa-solid fa-filter"></i>
3434
<span class="caret"></span>
3535
</button>

dojo/templates/dojo/breadcrumbs/custom_breadcrumb.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
{% load i18n %}
12
{% if custom_breadcrumb %}
2-
<nav aria-label="breadcrumb">
3+
<nav aria-label="{% trans 'breadcrumb' %}">
34
<ol class="breadcrumb">
45
{% for key, value in custom_breadcrumb.items %}
56
<li><a href="{{value}}">{{key}}</a></li>

0 commit comments

Comments
 (0)