diff --git a/docs/development/internationalization.md b/docs/development/internationalization.md index bdc7cbdaa..bebc97470 100644 --- a/docs/development/internationalization.md +++ b/docs/development/internationalization.md @@ -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):
{% trans "Circuit List" %}
{# 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 %} ``` diff --git a/netbox/templates/circuits/circuit_terminations_swap.html b/netbox/templates/circuits/circuit_terminations_swap.html index 7c9094d42..1ddb67bac 100644 --- a/netbox/templates/circuits/circuit_terminations_swap.html +++ b/netbox/templates/circuits/circuit_terminations_swap.html @@ -4,14 +4,18 @@ {% block title %}{% trans "Swap Circuit Terminations" %}{% endblock %} {% block message %} -

{% blocktrans %}Swap these terminations for circuit {{ circuit }}?{% endblocktrans %}

+

+ {% blocktrans trimmed %} + Swap these terminations for circuit {{ circuit }}? + {% endblocktrans %} +

diff --git a/netbox/templates/dcim/bulk_disconnect.html b/netbox/templates/dcim/bulk_disconnect.html index ede0df357..555ed635b 100644 --- a/netbox/templates/dcim/bulk_disconnect.html +++ b/netbox/templates/dcim/bulk_disconnect.html @@ -6,7 +6,7 @@ {% block message %}

- {% 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 %}

diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index f955c9cf8..676f8a3e5 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -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 %} diff --git a/netbox/templates/dcim/devicebay_delete.html b/netbox/templates/dcim/devicebay_delete.html index 47e2ba545..18f4f6576 100644 --- a/netbox/templates/dcim/devicebay_delete.html +++ b/netbox/templates/dcim/devicebay_delete.html @@ -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 %} -

{% blocktrans %}Are you sure you want to delete this device bay from {{ devicebay.device }}?{% endblocktrans %}

+

+ {% blocktrans trimmed %} + Are you sure you want to delete this device bay from {{ devicebay.device }}? + {% endblocktrans %} +

{% endblock %} diff --git a/netbox/templates/dcim/devicebay_depopulate.html b/netbox/templates/dcim/devicebay_depopulate.html index a0c026800..b094f5993 100644 --- a/netbox/templates/dcim/devicebay_depopulate.html +++ b/netbox/templates/dcim/devicebay_depopulate.html @@ -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 %}

- {% blocktrans with device=device_bay.installed_device %} + {% blocktrans trimmed with device=device_bay.installed_device %} Are you sure you want to remove {{ device }} from {{ device_bay }}? {% endblocktrans %}

diff --git a/netbox/templates/dcim/devicetype/component_templates.html b/netbox/templates/dcim/devicetype/component_templates.html index a2dcb6c0e..9a5210762 100644 --- a/netbox/templates/dcim/devicetype/component_templates.html +++ b/netbox/templates/dcim/devicetype/component_templates.html @@ -27,7 +27,7 @@
- {% blocktrans %}Add {{ title }}{% endblocktrans %} + {% trans "Add" %} {{ title }}
diff --git a/netbox/templates/dcim/moduletype/component_templates.html b/netbox/templates/dcim/moduletype/component_templates.html index 63cc1bb99..bb54a33f9 100644 --- a/netbox/templates/dcim/moduletype/component_templates.html +++ b/netbox/templates/dcim/moduletype/component_templates.html @@ -27,7 +27,7 @@
- {% blocktrans %}Add {{ title }}{% endblocktrans %} + {% trans "Add" %} {{ title }}
diff --git a/netbox/templates/dcim/rack/base.html b/netbox/templates/dcim/rack/base.html index 27ac284a2..2f4eb227c 100644 --- a/netbox/templates/dcim/rack/base.html +++ b/netbox/templates/dcim/rack/base.html @@ -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 }} diff --git a/netbox/templates/dcim/virtualchassis_add_member.html b/netbox/templates/dcim/virtualchassis_add_member.html index 6f9b24183..ceb2c71b3 100644 --- a/netbox/templates/dcim/virtualchassis_add_member.html +++ b/netbox/templates/dcim/virtualchassis_add_member.html @@ -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 %}
diff --git a/netbox/templates/dcim/virtualchassis_edit.html b/netbox/templates/dcim/virtualchassis_edit.html index cfc3de2ec..b8f232fc2 100644 --- a/netbox/templates/dcim/virtualchassis_edit.html +++ b/netbox/templates/dcim/virtualchassis_edit.html @@ -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 %} diff --git a/netbox/templates/dcim/virtualchassis_remove_member.html b/netbox/templates/dcim/virtualchassis_remove_member.html index 520f3d862..363c2b195 100644 --- a/netbox/templates/dcim/virtualchassis_remove_member.html +++ b/netbox/templates/dcim/virtualchassis_remove_member.html @@ -6,7 +6,7 @@ {% block message %}

- {% blocktrans with name=device.virtual_chassis %} + {% blocktrans trimmed with name=device.virtual_chassis %} Are you sure you want to remove {{ device }} from virtual chassis {{ name }}? {% endblocktrans %}

diff --git a/netbox/templates/exceptions/import_error.html b/netbox/templates/exceptions/import_error.html index 85803da0a..1996412e1 100644 --- a/netbox/templates/exceptions/import_error.html +++ b/netbox/templates/exceptions/import_error.html @@ -8,7 +8,7 @@

{% trans "Missing required packages" %}. - {% blocktrans %} + {% blocktrans trimmed %} This installation of NetBox might be missing one or more required Python packages. These packages are listed in requirements.txt and local_requirements.txt, and are normally installed as part of the installation or upgrade process. To verify installed packages, run pip freeze from the console and @@ -18,7 +18,7 @@

{% trans "WSGI service not restarted after upgrade" %}. - {% 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 %} diff --git a/netbox/templates/exceptions/permission_error.html b/netbox/templates/exceptions/permission_error.html index 334c3d0bd..778508117 100644 --- a/netbox/templates/exceptions/permission_error.html +++ b/netbox/templates/exceptions/permission_error.html @@ -8,7 +8,7 @@

{% trans "Insufficient write permission to the media root" %}. - {% blocktrans with media_root=settings.MEDIA_ROOT %} + {% blocktrans trimmed with media_root=settings.MEDIA_ROOT %} The configured media root is {{ media_root }}. Ensure that the user NetBox runs as has access to write files to all locations within this path. {% endblocktrans %} diff --git a/netbox/templates/exceptions/programming_error.html b/netbox/templates/exceptions/programming_error.html index d24378f7c..fdcbcbda0 100644 --- a/netbox/templates/exceptions/programming_error.html +++ b/netbox/templates/exceptions/programming_error.html @@ -8,7 +8,7 @@

{% trans "Database migrations missing" %}. - {% 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 python3 manage.py migrate from the command line. {% endblocktrans %} @@ -16,7 +16,7 @@

{% trans "Unsupported PostgreSQL version" %}. - {% 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 SELECT VERSION(). {% endblocktrans %} diff --git a/netbox/templates/extras/dashboard/reset.html b/netbox/templates/extras/dashboard/reset.html index ceb032c0d..b163cabb7 100644 --- a/netbox/templates/extras/dashboard/reset.html +++ b/netbox/templates/extras/dashboard/reset.html @@ -4,6 +4,14 @@ {% block title %}{% trans "Reset Dashboard" %}?{% endblock %} {% block message %} -

{% blocktrans %}This will remove all configured widgets and restore the default dashboard configuration.{% endblocktrans %}

-

{% blocktrans %}This change affects only your dashboard, and will not impact other users.{% endblocktrans %}

+

+ {% blocktrans trimmed %} + This will remove all configured widgets and restore the default dashboard configuration. + {% endblocktrans %} +

+

+ {% blocktrans trimmed %} + This change affects only your dashboard, and will not impact other users. + {% endblocktrans %} +

{% endblock %} diff --git a/netbox/templates/extras/dashboard/widgets/bookmarks.html b/netbox/templates/extras/dashboard/widgets/bookmarks.html index e8638d20e..80eb6238e 100644 --- a/netbox/templates/extras/dashboard/widgets/bookmarks.html +++ b/netbox/templates/extras/dashboard/widgets/bookmarks.html @@ -11,6 +11,6 @@ {% else %}

- {% blocktrans %}No bookmarks have been added yet.{% endblocktrans %} + {% trans "No bookmarks have been added yet." %}

{% endif %} diff --git a/netbox/templates/extras/objectchange.html b/netbox/templates/extras/objectchange.html index d681ecd75..63f2019ae 100644 --- a/netbox/templates/extras/objectchange.html +++ b/netbox/templates/extras/objectchange.html @@ -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 %}
- {% blocktrans with count=related_changes_count|add:"1" %}See All {{ count }} Changes{% endblocktrans %} + + {% blocktrans trimmed with count=related_changes_count|add:"1" %} + See All {{ count }} Changes + {% endblocktrans %} +
{% endif %} diff --git a/netbox/templates/extras/report_list.html b/netbox/templates/extras/report_list.html index 81b5beb3b..49353f9cc 100644 --- a/netbox/templates/extras/report_list.html +++ b/netbox/templates/extras/report_list.html @@ -117,7 +117,7 @@

{% trans "No Reports Found" %}

{% if perms.extras.add_reportmodule %} {% url 'extras:reportmodule_add' as create_report_url %} - {% blocktrans %} + {% blocktrans trimmed %} Get started by creating a report from an uploaded file or data source. {% endblocktrans %} {% endif %} diff --git a/netbox/templates/extras/script_list.html b/netbox/templates/extras/script_list.html index c78aedc1c..fc45bebc7 100644 --- a/netbox/templates/extras/script_list.html +++ b/netbox/templates/extras/script_list.html @@ -41,7 +41,7 @@ {% if not module.scripts %} @@ -91,7 +91,7 @@

{% trans "No Scripts Found" %}

{% if perms.extras.add_scriptmodule %} {% url 'extras:scriptmodule_add' as create_script_url %} - {% blocktrans %} + {% blocktrans trimmed %} Get started by creating a script from an uploaded file or data source. {% endblocktrans %} {% endif %} diff --git a/netbox/templates/generic/bulk_delete.html b/netbox/templates/generic/bulk_delete.html index 58b0e83ee..47aca4171 100644 --- a/netbox/templates/generic/bulk_delete.html +++ b/netbox/templates/generic/bulk_delete.html @@ -24,7 +24,7 @@ Context:

{% trans "Confirm Bulk Deletion" %}


{% trans "Warning" context "Noun" %}: - {% 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 {{ count }} {{ type_plural }}. Please carefully review the objects to be deleted and confirm below. {% endblocktrans %} diff --git a/netbox/templates/generic/bulk_import.html b/netbox/templates/generic/bulk_import.html index f7d8aae77..69c98f7ac 100644 --- a/netbox/templates/generic/bulk_import.html +++ b/netbox/templates/generic/bulk_import.html @@ -189,11 +189,15 @@ Context:

- {% blocktrans %}Required fields must be specified for all objects.{% endblocktrans %} + {% blocktrans trimmed %} + Required fields must be specified for all objects. + {% endblocktrans %}

- {% blocktrans with example="vrf.rd" %}Related objects may be referenced by any unique attribute. For example, {{ example }} 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, {{ example }} would identify a VRF by its route distinguisher. + {% endblocktrans %}

{% endif %} diff --git a/netbox/templates/generic/bulk_remove.html b/netbox/templates/generic/bulk_remove.html index 2691fbd3a..0c76897db 100644 --- a/netbox/templates/generic/bulk_remove.html +++ b/netbox/templates/generic/bulk_remove.html @@ -12,13 +12,13 @@