Skip to content

Commit

Permalink
Added gettext support to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
peteeckel committed Sep 30, 2024
1 parent ea9f71e commit 219e80b
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 171 deletions.
11 changes: 6 additions & 5 deletions netbox_dns/templates/netbox_dns/nameserver.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{% extends 'generic/object.html' %}
{% load i18n %}

{% block content %}
<div class="row">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">Name Server</h5>
<h5 class="card-header">{% trans "Nameserver" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
{% if unicode_name %}
<tr>
<th scope="row">IDN</th>
<th scope="row">{% trans "IDN" %}</th>
<td>{{ unicode_name }}</td>
</tr>
{% endif %}
{% if object.description %}
<tr>
<th scope="row">Description</th>
<th scope="row">{% trans "Description" %}</th>
<td style="word-break:break-all;">{{ object.description }}</td>
</tr>
{% endif %}
<tr>
<th scope="row">Tenant</th>
<th scope="row">{% trans "Tenant" %}</th>
<td>
{% if object.tenant.group %}
{{ object.tenant.group|linkify }} /
Expand Down
59 changes: 39 additions & 20 deletions netbox_dns/templates/netbox_dns/record.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load plugins %}
{% load render_table from django_tables2 %}
{% load perms %}
{% load i18n %}

{% block control-buttons %}
{% if object.managed %}
Expand All @@ -14,7 +15,7 @@
{% block breadcrumbs %}
{% if object.managed %}
<li class="breadcrumb-item">
<a href="{% url 'plugins:netbox_dns:managed_record_list' %}">{{ 'Managed Records' }}</a>
<a href="{% url 'plugins:netbox_dns:managed_record_list' %}">{% trans "Managed Records" %}</a>
</li>
{% else %}
{{ block.super }}
Expand All @@ -36,20 +37,20 @@
<div class="col col-md-8">
{% endif %}
<div class="card">
<h5 class="card-header">Record</h5>
<h5 class="card-header">{% trans "Record" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<th scope="row">{% trans "Name" %}</th>
<td style="word-break:break-all;">{{ object.name }}</td>
</tr>
{% if unicode_name %}
<tr>
<th scope="row">IDN</th>
<th scope="row">{% trans "IDN" %}</th>
<td style="word-break:break-all;">{{ unicode_name }}</td>
</tr>
{% endif %}
<tr>
<th scope="row">Zone</th>
<th scope="row">{% trans "Zone" %}</th>
{% if object.managed %}
<td><a href="{% url 'plugins:netbox_dns:zone_managed_records' pk=object.zone.pk %}">{{ object.zone }}</a></td>
{% else %}
Expand All @@ -58,7 +59,7 @@ <h5 class="card-header">Record</h5>
</tr>
{% if not object.managed or object.tenant %}
<tr>
<th scope="row">Tenant</th>
<th scope="row">{% trans "Tenant" %}</th>
<td>
{% if object.tenant.group %}
{{ object.tenant.group|linkify }} /
Expand All @@ -68,50 +69,50 @@ <h5 class="card-header">Record</h5>
</tr>
{% endif %}
<tr>
<th scope="row">Type</th>
<th scope="row">{% trans "Type" %}</th>
<td>{{ object.type }}</td>
</tr>
<tr>
<th scope="row">Value</th>
<th scope="row">{% trans "Value" %}</th>
<td style="word-break:break-all;">{{ object.value }}</td>
</tr>
{% if unicode_value %}
<tr>
<th scope="row">Unicode Value</th>
<th scope="row">{% trans "Unicode Value" %}</th>
<td style="word-break:break-all;">{{ unicode_value }}</td>
</tr>
{% endif %}
<tr>
<th scope="row">TTL</th>
<th scope="row">{% trans "TTL" %}</th>
<td>{{ object.ttl|placeholder }}</td>
</tr>
{% if object.type == 'A' or object.type == 'AAAA' %}
<tr>
<th scope="row">Disable PTR</th>
<th scope="row">{% trans "Disable PTR" %}</th>
<td>{% checkmark object.disable_ptr %}</td>
</tr>
{% endif %}
{% if object.ptr_record %}
<tr>
<th scope="row">PTR Record</th>
<th scope="row">{% trans "PTR Record" %}</th>
<td>{{ object.ptr_record|linkify }}</td>
</tr>
{% endif %}
{% if object.address_record %}
<tr>
<th scope="row">Address Record</th>
<th scope="row">{% trans "Address Record" %}</th>
<td>{{ object.address_record|linkify }}</td>
</tr>
{% if object.address_record.ipam_ip_address %}
<tr>
<th scope="row">IPAM IP Address</th>
<th scope="row">{% trans "IPAM IP Address" %}</th>
<td>{{ object.address_record.ipam_ip_address|linkify }}</td>
</tr>
{% endif %}
{% endif %}
{% if object.ipam_ip_address %}
<tr>
<th scope="row">IPAM IP Address</th>
<th scope="row">{% trans "IPAM IP Address" %}</th>
<td>{{ object.ipam_ip_address|linkify }}</td>
</tr>
{% endif %}
Expand All @@ -121,16 +122,34 @@ <h5 class="card-header">Record</h5>
</tr>
{% if object.description %}
<tr>
<th scope="row">Description</th>
<th scope="row">{% trans "Description" %}</th>
<td style="word-break:break-all;">{{ object.description }}</td>
</tr>
{% endif %}
</table>
</div>
{% if cname_target_table and cname_target_table.rows|length > 0 %}
{% include 'inc/panel_table.html' with table=cname_target_table heading='CNAME Targets' %}
{% elif cname_table and cname_table.rows|length > 0 %}
{% include 'inc/panel_table.html' with table=cname_table heading='CNAMEs' %}
{% if cname_target_table %}
<div class="card">
{% if cname_target_table.rows|length == 1 %}
<h2 class="card-header">{% trans "CNAME Target" %}</h2>
{% else %}
<h2 class="card-header">{% trans "CNAME Targets" %}</h2>
{% endif %}
<div class="table-responsive">
{% render_table cname_target_table 'inc/table.html' %}
</div>
</div>
{% elif cname_table %}
<div class="card">
{% if cname_table.rows|length == 1 %}
<h2 class="card-header">{% trans "CNAME" %}</h2>
{% else %}
<h2 class="card-header">{% trans "CNAMEs" %}</h2>
{% endif %}
<div class="table-responsive">
{% render_table cname_table 'inc/table.html' %}
</div>
</div>
{% endif %}
{% if not object.managed %}
{% include 'inc/panels/custom_fields.html' %}
Expand Down
3 changes: 2 additions & 1 deletion netbox_dns/templates/netbox_dns/record/managed.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% extends 'generic/object_list.html' %}
{% load i18n %}

{% block title %}Managed Records{% endblock %}
{% block title %}{% trans "Managed Records" %}{% endblock %}
40 changes: 26 additions & 14 deletions netbox_dns/templates/netbox_dns/record/related.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
{% load render_table from django_tables2 %}
{% load perms %}
{% load i18n %}

{% if perms.netbox_dns.view_record %}
{% if related_address_records %}
{% if related_address_records.rows|length == 1 %}
{% include 'inc/panel_table.html' with table=related_address_records heading='Related DNS Address Record' %}
{% else %}
{% include 'inc/panel_table.html' with table=related_address_records heading='Related DNS Address Records' %}
{% endif %}
{% endif %}
{% if related_pointer_records %}
{% if related_pointer_records.rows|length == 1 %}
{% include 'inc/panel_table.html' with table=related_pointer_records heading='Related DNS Pointer Record' %}
{% else %}
{% include 'inc/panel_table.html' with table=related_pointer_records heading='Related DNS Pointer Records' %}
{% endif %}
{% endif %}
{% if related_address_records %}
<div class="card">
{% if related_address_records.rows|length == 1 %}
<h2 class="card-header">{% trans "Related DNS Address Record" %}</h2>
{% else %}
<h2 class="card-header">{% trans "Related DNS Address Records" %}</h2>
{% endif %}
<div class="table-responsive">
{% render_table related_address_records 'inc/table.html' %}
</div>
</div>
{% endif %}
{% if related_pointer_records %}
<div class="card">
{% if related_pointer_records.rows|length == 1 %}
<h2 class="card-header">{% trans "Related DNS Pointer Record" %}</h2>
{% else %}
<h2 class="card-header">{% trans "Related DNS Pointer Records" %}</h2>
{% endif %}
<div class="table-responsive">
{% render_table related_pointer_records 'inc/table.html' %}
</div>
</div>
{% endif %}
{% endif %}
42 changes: 27 additions & 15 deletions netbox_dns/templates/netbox_dns/recordtemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
{% load plugins %}
{% load render_table from django_tables2 %}
{% load perms %}
{% load i18n %}

{% block content %}
<div class="row">
<div class="col col-md-8">
<div class="card">
<h5 class="card-header">Record Template</h5>
<h5 class="card-header">{% trans "Record Template" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Template Name</th>
<th scope="row">{% trans "Template Name" %}</th>
<td style="word-break:break-all;">{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Name</th>
<th scope="row">{% trans "Name" %}</th>
<td style="word-break:break-all;">{{ object.record_name }}</td>
</tr>
{% if unicode_name %}
<tr>
<th scope="row">IDN</th>
<th scope="row">{% trans "IDN" %}</th>
<td style="word-break:break-all;">{{ unicode_name }}</td>
</tr>
{% endif %}
{% if object.tenant %}
<tr>
<th scope="row">Tenant</th>
<th scope="row">{% trans "Tenant" %}</th>
<td>
{% if object.tenant.group %}
{{ object.tenant.group|linkify }} /
Expand All @@ -36,36 +37,36 @@ <h5 class="card-header">Record Template</h5>
</tr>
{% endif %}
<tr>
<th scope="row">Type</th>
<th scope="row">{% trans "Type" %}</th>
<td>{{ object.type }}</td>
</tr>
<tr>
<th scope="row">Value</th>
<th scope="row">{% trans "Value" %}</th>
<td style="word-break:break-all;">{{ object.value }}</td>
</tr>
{% if unicode_value %}
<tr>
<th scope="row">Unicode Value</th>
<th scope="row">{% trans "Unicode Value" %}/th>
<td style="word-break:break-all;">{{ unicode_value }}</td>
</tr>
{% endif %}
<tr>
<th scope="row">TTL</th>
<th scope="row">{% trans "TTL" %}</th>
<td>{{ object.ttl|placeholder }}</td>
</tr>
{% if object.type == 'A' or object.type == 'AAAA' %}
<tr>
<th scope="row">Disable PTR</th>
<th scope="row">{% trans "Disable PTR" %}</th>
<td>{% checkmark object.disable_ptr %}</td>
</tr>
{% endif %}
<tr>
<th scope="row">Status</th>
<th scope="row">{% trans "Status" %}</th>
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
</tr>
{% if object.description %}
<tr>
<th scope="row">Description</th>
<th scope="row">{% trans "Description" %}</th>
<td style="word-break:break-all;">{{ object.description }}</td>
</tr>
{% endif %}
Expand All @@ -76,9 +77,20 @@ <h5 class="card-header">Record Template</h5>
<div class="col col-md-4">
{% include 'inc/panels/tags.html' %}
</div>
<div class="col col-md-12">
{% include 'inc/panel_table.html' with table=zone_template_table heading="Zone Templates" %}
</div>
{% if zone_template_table %}
<div class="col col-md-12">
<div class="card">
{% if zone_template_table.rows|length == 1 %}
<h2 class="card-header">{% trans "Zone Template" %}</h2>
{% else %}
<h2 class="card-header">{% trans "Zone Templates" %}</h2>
{% endif %}
<div class="table-responsive">
{% render_table zone_template_table 'inc/table.html' %}
</div>
</div>
</div>
{% endif %}
</div>

{% endblock %}
Loading

0 comments on commit 219e80b

Please sign in to comment.