1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Clean up blocktrans template tags (i18n)

This commit is contained in:
Jeremy Stretch
2023-09-11 16:17:02 -04:00
parent 75b71890a4
commit 39cb9c32d6
31 changed files with 76 additions and 46 deletions

View File

@ -97,7 +97,7 @@ class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
1. Ensure translation support is enabled by including `{% load i18n %}` at the top of the template.
2. Use the [`{% trans %}`](https://docs.djangoproject.com/en/stable/topics/i18n/translation/#translate-template-tag) tag (short for "translate") to wrap short strings.
3. Longer strings may be enclosed between [`{% blocktrans %}`](https://docs.djangoproject.com/en/stable/topics/i18n/translation/#blocktranslate-template-tag) and `{% endblocktrans %}` tags to improve readability and to enable variable replacement.
3. Longer strings may be enclosed between [`{% blocktrans %}`](https://docs.djangoproject.com/en/stable/topics/i18n/translation/#blocktranslate-template-tag) and `{% endblocktrans %}` tags to improve readability and to enable variable replacement. (Remember to include the `trimmed` argument to trim whitespace between the tags.)
4. Avoid passing HTML within translated strings where possible, as this can complicate the work needed of human translators to develop message maps.
```
@ -107,7 +107,7 @@ class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
<h5 class="card-header">{% trans "Circuit List" %}</h5>
{# A longer string with a context variable #}
{% blocktrans with count=object.circuits.count %}
{% blocktrans trimmed with count=object.circuits.count %}
There are {count} circuits. Would you like to continue?
{% endblocktrans %}
```

View File

@ -4,14 +4,18 @@
{% block title %}{% trans "Swap Circuit Terminations" %}{% endblock %}
{% block message %}
<p>{% blocktrans %}Swap these terminations for circuit {{ circuit }}?{% endblocktrans %}</p>
<p>
{% blocktrans trimmed %}
Swap these terminations for circuit {{ circuit }}?
{% endblocktrans %}
</p>
<ul>
<li>
<strong>{% trans "A side" %}:</strong>
{% if termination_a %}
{{ termination_a.site }} {% if termination_a.interface %}- {{ termination_a.interface.device }} {{ termination_a.interface }}{% endif %}
{% else %}
{{ ''|placeholder }}
{% trans "None" %}
{% endif %}
</li>
<li>
@ -19,7 +23,7 @@
{% if termination_z %}
{{ termination_z.site }} {% if termination_z.interface %}- {{ termination_z.interface.device }} {{ termination_z.interface }}{% endif %}
{% else %}
{{ ''|placeholder }}
{% trans "None" %}
{% endif %}
</li>
</ul>

View File

@ -6,7 +6,7 @@
{% block message %}
<p>
{% blocktrans with count=selected_objects|length %}
{% blocktrans trimmed with count=selected_objects|length %}
Are you sure you want to disconnect these {{ count }} {{ obj_type_plural }}?
{% endblocktrans %}
</p>

View File

@ -3,7 +3,7 @@
{% load i18n %}
{% block title %}
{% blocktrans with object_type=object|meta:"verbose_name"|bettertitle %}
{% blocktrans trimmed with object_type=object|meta:"verbose_name"|bettertitle %}
Cable Trace for {{ object_type }} {{ object }}
{% endblocktrans %}
{% endblock %}

View File

@ -2,8 +2,14 @@
{% load form_helpers %}
{% load i18n %}
{% block title %}{% blocktrans %}Delete device bay {{ devicebay }}?{% endblocktrans %}{% endblock %}
{% block title %}
{% blocktrans %}Delete device bay {{ devicebay }}?{% endblocktrans %}
{% endblock %}
{% block message %}
<p>{% blocktrans %}Are you sure you want to delete this device bay from <strong>{{ devicebay.device }}</strong>?{% endblocktrans %}</p>
<p>
{% blocktrans trimmed %}
Are you sure you want to delete this device bay from <strong>{{ devicebay.device }}</strong>?
{% endblocktrans %}
</p>
{% endblock %}

View File

@ -3,14 +3,14 @@
{% load i18n %}
{% block title %}
{% blocktrans with device=device_bay.installed_device %}
{% blocktrans trimmed with device=device_bay.installed_device %}
Remove {{ device }} from {{ device_bay }}?
{% endblocktrans %}
{% endblock %}
{% block message %}
<p>
{% blocktrans with device=device_bay.installed_device %}
{% blocktrans trimmed with device=device_bay.installed_device %}
Are you sure you want to remove <strong>{{ device }}</strong> from <strong>{{ device_bay }}</strong>?
{% endblocktrans %}
</p>

View File

@ -27,7 +27,7 @@
<div class="float-end">
<a href="{% url table.Meta.model|viewname:"add" %}?device_type={{ object.pk }}&return_url={{ return_url }}" class="btn btn-primary btn-sm">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
{% blocktrans %}Add {{ title }}{% endblocktrans %}
{% trans "Add" %} {{ title }}
</a>
</div>
<div class="clearfix"></div>

View File

@ -27,7 +27,7 @@
<div class="float-end">
<a href="{% url table.Meta.model|viewname:"add" %}?module_type={{ object.pk }}&return_url={{ return_url }}" class="btn btn-primary btn-sm">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
{% blocktrans %}Add {{ title }}{% endblocktrans %}
{% trans "Add" %} {{ title }}
</a>
</div>
<div class="clearfix"></div>

View File

@ -1,7 +1,7 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% block title %}{% blocktrans %}Rack {{ object }}{% endblocktrans %}{% endblock %}
{% block title %}{% trans "Rack" %} {{ object }}{% endblock %}
{% block breadcrumbs %}
{{ block.super }}

View File

@ -2,7 +2,11 @@
{% load form_helpers %}
{% load i18n %}
{% block title %}{% blocktrans %}Add New Member to Virtual Chassis {{ virtual_chassis }}{% endblocktrans %}{% endblock %}
{% block title %}
{% blocktrans trimmed %}
Add New Member to Virtual Chassis {{ virtual_chassis }}
{% endblocktrans %}
{% endblock %}
{% block content %}
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit">

View File

@ -4,7 +4,7 @@
{% load i18n %}
{% block title %}
{% blocktrans with name=vc_form.instance %}
{% blocktrans trimmed with name=vc_form.instance %}
Editing Virtual Chassis {{ name }}
{% endblocktrans %}
{% endblock %}

View File

@ -6,7 +6,7 @@
{% block message %}
<p>
{% blocktrans with name=device.virtual_chassis %}
{% blocktrans trimmed with name=device.virtual_chassis %}
Are you sure you want to remove <strong>{{ device }}</strong> from virtual chassis {{ name }}?
{% endblocktrans %}
</p>

View File

@ -8,7 +8,7 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Missing required packages" %}.</strong>
{% blocktrans %}
{% blocktrans trimmed %}
This installation of NetBox might be missing one or more required Python packages. These packages are listed in
<code>requirements.txt</code> and <code>local_requirements.txt</code>, and are normally installed as part of the
installation or upgrade process. To verify installed packages, run <code>pip freeze</code> from the console and
@ -18,7 +18,7 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "WSGI service not restarted after upgrade" %}.</strong>
{% blocktrans %}
{% blocktrans trimmed %}
If this installation has recently been upgraded, check that the WSGI service (e.g. gunicorn or uWSGI) has been
restarted. This ensures that the new code is running.
{% endblocktrans %}

View File

@ -8,7 +8,7 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Insufficient write permission to the media root" %}.</strong>
{% blocktrans with media_root=settings.MEDIA_ROOT %}
{% blocktrans trimmed with media_root=settings.MEDIA_ROOT %}
The configured media root is <code>{{ media_root }}</code>. Ensure that the user NetBox runs as has access to
write files to all locations within this path.
{% endblocktrans %}

View File

@ -8,7 +8,7 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Database migrations missing" %}.</strong>
{% blocktrans %}
{% blocktrans trimmed %}
When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You
can run migrations manually by executing <code>python3 manage.py migrate</code> from the command line.
{% endblocktrans %}
@ -16,7 +16,7 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Unsupported PostgreSQL version" %}.</strong>
{% blocktrans %}
{% blocktrans trimmed %}
Ensure that PostgreSQL version 12 or later is in use. You can check this by connecting to the database using
NetBox's credentials and issuing a query for <code>SELECT VERSION()</code>.
{% endblocktrans %}

View File

@ -4,6 +4,14 @@
{% block title %}{% trans "Reset Dashboard" %}?{% endblock %}
{% block message %}
<p>{% blocktrans %}This will remove <strong>all</strong> configured widgets and restore the default dashboard configuration.{% endblocktrans %}</p>
<p>{% blocktrans %}This change affects only <i>your</i> dashboard, and will not impact other users.{% endblocktrans %}</p>
<p>
{% blocktrans trimmed %}
This will remove <strong>all</strong> configured widgets and restore the default dashboard configuration.
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
This change affects only <i>your</i> dashboard, and will not impact other users.
{% endblocktrans %}
</p>
{% endblock %}

View File

@ -11,6 +11,6 @@
{% else %}
<p class="text-center text-muted">
<i class="mdi mdi-information-outline"></i>
{% blocktrans %}No bookmarks have been added yet.{% endblocktrans %}
{% trans "No bookmarks have been added yet." %}
</p>
{% endif %}

View File

@ -153,7 +153,11 @@
{% include 'inc/panel_table.html' with table=related_changes_table heading='Related Changes' panel_class='default' %}
{% if related_changes_count > related_changes_table.rows|length %}
<div class="float-end">
<a href="{% url 'extras:objectchange_list' %}?request_id={{ object.request_id }}" class="btn btn-primary">{% blocktrans with count=related_changes_count|add:"1" %}See All {{ count }} Changes{% endblocktrans %}</a>
<a href="{% url 'extras:objectchange_list' %}?request_id={{ object.request_id }}" class="btn btn-primary">
{% blocktrans trimmed with count=related_changes_count|add:"1" %}
See All {{ count }} Changes
{% endblocktrans %}
</a>
</div>
{% endif %}
</div>

View File

@ -117,7 +117,7 @@
<h4 class="alert-heading">{% trans "No Reports Found" %}</h4>
{% if perms.extras.add_reportmodule %}
{% url 'extras:reportmodule_add' as create_report_url %}
{% blocktrans %}
{% blocktrans trimmed %}
Get started by <a href="{{ create_report_url }}">creating a report</a> from an uploaded file or data source.
{% endblocktrans %}
{% endif %}

View File

@ -41,7 +41,7 @@
{% if not module.scripts %}
<div class="alert alert-warning d-flex align-items-center" role="alert">
<i class="mdi mdi-alert"></i>
{% blocktrans with file_path=module.full_path %}
{% blocktrans trimmed with file_path=module.full_path %}
Script file at <code>{{ file_path }}</code> could not be loaded.
{% endblocktrans %}
</div>
@ -91,7 +91,7 @@
<h4 class="alert-heading">{% trans "No Scripts Found" %}</h4>
{% if perms.extras.add_scriptmodule %}
{% url 'extras:scriptmodule_add' as create_script_url %}
{% blocktrans %}
{% blocktrans trimmed %}
Get started by <a href="{{ create_script_url }}">creating a script</a> from an uploaded file or data source.
{% endblocktrans %}
{% endif %}

View File

@ -24,7 +24,7 @@ Context:
<h4 class="alert-heading">{% trans "Confirm Bulk Deletion" %}</h4>
<hr />
<strong>{% trans "Warning" context "Noun" %}:</strong>
{% blocktrans with count=table.rows|length type_plural=model|meta:"verbose_name_plural" %}
{% blocktrans trimmed with count=table.rows|length type_plural=model|meta:"verbose_name_plural" %}
The following operation will delete <strong>{{ count }}</strong> {{ type_plural }}. Please
carefully review the objects to be deleted and confirm below.
{% endblocktrans %}

View File

@ -189,11 +189,15 @@ Context:
</div>
<p class="small text-muted">
<i class="mdi mdi-check-bold text-success"></i>
{% blocktrans %}Required fields <strong>must</strong> be specified for all objects.{% endblocktrans %}
{% blocktrans trimmed %}
Required fields <strong>must</strong> be specified for all objects.
{% endblocktrans %}
</p>
<p class="small text-muted">
<i class="mdi mdi-information-outline"></i>
{% blocktrans with example="vrf.rd" %}Related objects may be referenced by any unique attribute. For example, <code>{{ example }}</code> would identify a VRF by its route distinguisher.{% endblocktrans %}
{% blocktrans trimmed with example="vrf.rd" %}
Related objects may be referenced by any unique attribute. For example, <code>{{ example }}</code> would identify a VRF by its route distinguisher.
{% endblocktrans %}
</p>
{% endif %}

View File

@ -12,13 +12,13 @@
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">{% trans "Confirm Bulk Removal" %}</h4>
<p>
{% blocktrans with count=table.rows|length %}
{% blocktrans trimmed with count=table.rows|length %}
<strong>Warning:</strong> The following operation will remove {{ count }} {{ obj_type_plural }} from {{ parent_obj }}.
{% endblocktrans %}
</p>
<hr />
<p class="mb-0">
{% blocktrans %}
{% blocktrans trimmed %}
Please carefully review the {{ obj_type_plural }} to be removed and confirm below.
{% endblocktrans %}
</p>
@ -35,7 +35,7 @@
{% endfor %}
<div class="text-center">
<button type="submit" name="_confirm" class="btn btn-danger">
{% blocktrans with count=table.rows|length %}
{% blocktrans trimmed with count=table.rows|length %}
Delete these {{ count }} {{ obj_type_plural }}
{% endblocktrans %}
</button>

View File

@ -16,7 +16,7 @@ Context:
{% if object.pk %}
{% trans "Editing" %} {{ object|meta:"verbose_name" }} {{ object }}
{% else %}
{% blocktrans with object_type=object|meta:"verbose_name" %}
{% blocktrans trimmed with object_type=object|meta:"verbose_name" %}
Add a new {{ object_type }}
{% endblocktrans %}
{% endif %}

View File

@ -91,7 +91,7 @@ Context:
<div class="form-check">
<input type="checkbox" id="select-all" name="_all" class="form-check-input" />
<label for="select-all" class="form-check-label">
{% blocktrans with count=table.rows|length object_type_plural=table.data.verbose_name_plural %}
{% blocktrans trimmed with count=table.rows|length object_type_plural=table.data.verbose_name_plural %}
Select <strong>all {{ count }} {{ object_type_plural }}</strong> matching query
{% endblocktrans %}
</label>

View File

@ -8,7 +8,7 @@
</div>
<div class="modal-body">
<p>
{% blocktrans %}
{% blocktrans trimmed %}
Are you sure you want to <strong class="text-danger">delete</strong> {{ object_type }} <strong>{{ object }}</strong>?
{% endblocktrans %}
</p>

View File

@ -4,7 +4,7 @@
<div class="alert alert-warning text-end" role="alert">
<div class="float-start">
<i class="mdi mdi-alert"></i>
{% blocktrans with model=model|meta:"verbose_name" prerequisite_model=prerequisite_model|meta:"verbose_name" %}
{% blocktrans trimmed with model=model|meta:"verbose_name" prerequisite_model=prerequisite_model|meta:"verbose_name" %}
Before you can add a {{ model }} you must first create a <strong>{{ prerequisite_model }}</strong>.
{% endblocktrans %}
</div>

View File

@ -46,7 +46,7 @@
</ul>
</div>
<small class="text-end text-muted">
{% blocktrans with start=page.start_index end=page.end_index total=page.paginator.count %}
{% blocktrans trimmed with start=page.start_index end=page.end_index total=page.paginator.count %}
Showing {{ start }}-{{ end }} of {{ total }}
{% endblocktrans %}
</small>

View File

@ -66,7 +66,7 @@
</ul>
</div>
<small class="text-end text-muted">
{% blocktrans with start=page.start_index end=page.end_index total=page.paginator.count %}
{% blocktrans trimmed with start=page.start_index end=page.end_index total=page.paginator.count %}
Showing {{ start }}-{{ end }} of {{ total }}
{% endblocktrans %}
</small>

View File

@ -26,13 +26,13 @@
<p>{% trans "Check the following" %}:</p>
<ul>
<li class="tip">
{% blocktrans %}
{% blocktrans trimmed %}
<code>manage.py collectstatic</code> was run during the most recent upgrade. This installs the most
recent iteration of each static file into the static root path.
{% endblocktrans %}
</li>
<li class="tip">
{% blocktrans with docs_url="https://docs.netbox.dev/en/stable/installation/" %}
{% blocktrans trimmed with docs_url="https://docs.netbox.dev/en/stable/installation/" %}
The HTTP service (e.g. nginx or Apache) is configured to serve files from the <code>STATIC_ROOT</code>
path. Refer to <a href="{{ docs_url }}">the installation documentation</a> for further guidance.
{% endblocktrans %}
@ -44,7 +44,7 @@
</ul>
</li>
<li class="tip">
{% blocktrans %}
{% blocktrans trimmed %}
The file <code>{{ filename }}</code> exists in the static root directory and is readable by the HTTP
server.
{% endblocktrans %}
@ -52,7 +52,7 @@
</ul>
<p>
{% url 'home' as home_url %}
{% blocktrans %}
{% blocktrans trimmed %}
Click <a href="{{ home_url }}">here</a> to attempt loading NetBox again.
{% endblocktrans %}
</p>

View File

@ -6,7 +6,7 @@
{% render_errors form %}
{% block title %}
{% blocktrans %}
{% blocktrans trimmed %}
Add Device to Cluster {{ cluster }}
{% endblocktrans %}
{% endblock %}