From 75b71890a4bcec91706cd16b9c01c61b65163fe3 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 11 Sep 2023 15:59:50 -0400 Subject: [PATCH] Misc i18n cleanup --- netbox/core/choices.py | 4 +- netbox/core/data_backends.py | 4 +- netbox/dcim/forms/bulk_import.py | 40 ++++++++++--------- netbox/dcim/models/device_components.py | 21 +++++----- netbox/dcim/models/power.py | 9 ++++- netbox/extras/forms/bulk_import.py | 2 +- netbox/extras/forms/model_forms.py | 10 +++-- netbox/extras/models/configs.py | 4 +- netbox/ipam/models/ip.py | 16 +------- netbox/templates/dcim/cable_trace.html | 6 +-- netbox/templates/dcim/powerfeed.html | 2 +- netbox/templates/exceptions/import_error.html | 15 +++---- .../exceptions/permission_error.html | 6 +-- .../exceptions/programming_error.html | 12 +++--- netbox/templates/generic/bulk_import.html | 2 +- 15 files changed, 77 insertions(+), 76 deletions(-) diff --git a/netbox/core/choices.py b/netbox/core/choices.py index 0067dfed8..b5d9d0d90 100644 --- a/netbox/core/choices.py +++ b/netbox/core/choices.py @@ -14,8 +14,8 @@ class DataSourceTypeChoices(ChoiceSet): CHOICES = ( (LOCAL, _('Local'), 'gray'), - (GIT, _('Git'), 'blue'), - (AMAZON_S3, _('Amazon S3'), 'blue'), + (GIT, 'Git', 'blue'), + (AMAZON_S3, 'Amazon S3', 'blue'), ) diff --git a/netbox/core/data_backends.py b/netbox/core/data_backends.py index d2dacbbe0..82b3962dd 100644 --- a/netbox/core/data_backends.py +++ b/netbox/core/data_backends.py @@ -81,13 +81,13 @@ class GitBackend(DataBackend): required=False, label=_('Username'), widget=forms.TextInput(attrs={'class': 'form-control'}), - help_text=_("Only used for cloning with HTTP / HTTPS"), + help_text=_("Only used for cloning with HTTP(S)"), ), 'password': forms.CharField( required=False, label=_('Password'), widget=forms.TextInput(attrs={'class': 'form-control'}), - help_text=_("Only used for cloning with HTTP / HTTPS"), + help_text=_("Only used for cloning with HTTP(S)"), ), 'branch': forms.CharField( required=False, diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index a8e75e3c2..74af0696b 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -118,7 +118,9 @@ class SiteImportForm(NetBoxModelImportForm): ) help_texts = { 'time_zone': mark_safe( - _('Time zone (available options)') + '{} ({})'.format( + _('Time zone'), _('available options') + ) ) } @@ -165,7 +167,7 @@ class RackRoleImportForm(NetBoxModelImportForm): model = RackRole fields = ('name', 'slug', 'color', 'description', 'tags') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } @@ -375,7 +377,7 @@ class DeviceRoleImportForm(NetBoxModelImportForm): model = DeviceRole fields = ('name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } @@ -790,7 +792,9 @@ class InterfaceImportForm(NetBoxModelImportForm): queryset=VirtualDeviceContext.objects.all(), required=False, to_field_name='name', - help_text=_('VDC names separated by commas, encased with double quotes (e.g. "vdc1, vdc2, vdc3")') + help_text=mark_safe( + _('VDC names separated by commas, encased with double quotes. Example:') + ' vdc1,vdc2,vdc3' + ) ) type = CSVChoiceField( label=_('Type'), @@ -1085,7 +1089,7 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm): model = InventoryItemRole fields = ('name', 'slug', 'color', 'description') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } @@ -1096,38 +1100,38 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm): class CableImportForm(NetBoxModelImportForm): # Termination A side_a_device = CSVModelChoiceField( - label=_('Side a device'), + label=_('Side A device'), queryset=Device.objects.all(), to_field_name='name', - help_text=_('Side A device') + help_text=_('Device name') ) side_a_type = CSVContentTypeField( - label=_('Side a type'), + label=_('Side A type'), queryset=ContentType.objects.all(), limit_choices_to=CABLE_TERMINATION_MODELS, - help_text=_('Side A type') + help_text=_('Termination type') ) side_a_name = forms.CharField( - label=_('Side a name'), - help_text=_('Side A component name') + label=_('Side A name'), + help_text=_('Termination name') ) # Termination B side_b_device = CSVModelChoiceField( - label=_('Side b device'), + label=_('Side B device'), queryset=Device.objects.all(), to_field_name='name', - help_text=_('Side B device') + help_text=_('Device name') ) side_b_type = CSVContentTypeField( - label=_('Side b type'), + label=_('Side B type'), queryset=ContentType.objects.all(), limit_choices_to=CABLE_TERMINATION_MODELS, - help_text=_('Side B type') + help_text=_('Termination type') ) side_b_name = forms.CharField( - label=_('Side b name'), - help_text=_('Side B component name') + label=_('Side B name'), + help_text=_('Termination name') ) # Cable attributes @@ -1164,7 +1168,7 @@ class CableImportForm(NetBoxModelImportForm): 'status', 'tenant', 'label', 'color', 'length', 'length_unit', 'description', 'comments', 'tags', ] help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } def _clean_side(self, side): diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index e18f25e4f..f42ae5895 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -799,9 +799,9 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd if self.bridge and self.bridge.device != self.device: if self.device.virtual_chassis is None: raise ValidationError({ - 'bridge': _(""" - The selected bridge interface ({bridge}) belongs to a different device - ({device}).""").format(bridge=self.bridge, device=self.bridge.device) + 'bridge': _( + "The selected bridge interface ({bridge}) belongs to a different device ({device})." + ).format(bridge=self.bridge, device=self.bridge.device) }) elif self.bridge.device.virtual_chassis != self.device.virtual_chassis: raise ValidationError({ @@ -889,10 +889,10 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd # Validate untagged VLAN if self.untagged_vlan and self.untagged_vlan.site not in [self.device.site, None]: raise ValidationError({ - 'untagged_vlan': _(""" - The untagged VLAN ({untagged_vlan}) must belong to the same site as the - interface's parent device, or it must be global. - """).format(untagged_vlan=self.untagged_vlan) + 'untagged_vlan': _( + "The untagged VLAN ({untagged_vlan}) must belong to the same site as the interface's parent " + "device, or it must be global." + ).format(untagged_vlan=self.untagged_vlan) }) def save(self, *args, **kwargs): @@ -1067,9 +1067,10 @@ class RearPort(ModularComponentModel, CabledObjectModel, TrackingModelMixin): frontport_count = self.frontports.count() if self.positions < frontport_count: raise ValidationError({ - "positions": _(""" - The number of positions cannot be less than the number of mapped front ports - ({frontport_count})""").format(frontport_count=frontport_count) + "positions": _( + "The number of positions cannot be less than the number of mapped front ports " + "({frontport_count})" + ).format(frontport_count=frontport_count) }) diff --git a/netbox/dcim/models/power.py b/netbox/dcim/models/power.py index 83e5eb23a..a852ea5cd 100644 --- a/netbox/dcim/models/power.py +++ b/netbox/dcim/models/power.py @@ -174,8 +174,13 @@ class PowerFeed(PrimaryModel, PathEndpoint, CabledObjectModel): # Rack must belong to same Site as PowerPanel if self.rack and self.rack.site != self.power_panel.site: - raise ValidationError(_("Rack {} ({}) and power panel {} ({}) are in different sites").format( - self.rack, self.rack.site, self.power_panel, self.power_panel.site + raise ValidationError(_( + "Rack {rack} ({site}) and power panel {powerpanel} ({powerpanel_site}) are in different sites" + ).format( + rack=self.rack, + rack_site=self.rack.site, + powerpanel=self.power_panel, + powerpanel_site=self.power_panel.site )) # AC voltage cannot be negative diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py index 466baa241..79023a74d 100644 --- a/netbox/extras/forms/bulk_import.py +++ b/netbox/extras/forms/bulk_import.py @@ -164,7 +164,7 @@ class TagImportForm(CSVModelForm): model = Tag fields = ('name', 'slug', 'color', 'description') help_texts = { - 'color': mark_safe(_('RGB color in hexadecimal (e.g. 00ff00)')), + 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' 00ff00'), } diff --git a/netbox/extras/forms/model_forms.py b/netbox/extras/forms/model_forms.py index d4e59c170..9fa7adb99 100644 --- a/netbox/extras/forms/model_forms.py +++ b/netbox/extras/forms/model_forms.py @@ -4,6 +4,7 @@ from django import forms from django.conf import settings from django.db.models import Q from django.contrib.contenttypes.models import ContentType +from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ from core.forms.mixins import SyncedDataMixin @@ -81,7 +82,8 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - # Disable changing the type of a CustomField as it almost universally causes errors if custom field data is already present. + # Disable changing the type of a CustomField as it almost universally causes errors if custom field data + # is already present. if self.instance.pk: self.fields['type'].disabled = True @@ -90,10 +92,10 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm): extra_choices = forms.CharField( widget=ChoicesWidget(), required=False, - help_text=_( + help_text=mark_safe(_( 'Enter one choice per line. An optional label may be specified for each choice by appending it with a ' - 'comma (for example, "choice1,First Choice").' - ) + 'comma. Example:' + ) + ' choice1,First Choice') ) class Meta: diff --git a/netbox/extras/models/configs.py b/netbox/extras/models/configs.py index 47e8dcd82..2acfcb725 100644 --- a/netbox/extras/models/configs.py +++ b/netbox/extras/models/configs.py @@ -146,7 +146,7 @@ class ConfigContext(SyncedDataMixin, CloningMixin, ChangeLoggedModel): # Verify that JSON data is provided as an object if type(self.data) is not dict: raise ValidationError( - {'data': _('JSON data must be in object form. Example: {"foo": 123}')} + {'data': _('JSON data must be in object form. Example:') + ' {"foo": 123}'} ) def sync_data(self): @@ -202,7 +202,7 @@ class ConfigContextModel(models.Model): # Verify that JSON data is provided as an object if self.local_context_data and type(self.local_context_data) is not dict: raise ValidationError( - {'local_context_data': _('JSON data must be in object form. Example: {"foo": 123}')} + {'local_context_data': _('JSON data must be in object form. Example:') + ' {"foo": 123}'} ) diff --git a/netbox/ipam/models/ip.py b/netbox/ipam/models/ip.py index 89977704a..2456fa021 100644 --- a/netbox/ipam/models/ip.py +++ b/netbox/ipam/models/ip.py @@ -554,25 +554,13 @@ class IPRange(PrimaryModel): # Check that start & end IP versions match if self.start_address.version != self.end_address.version: raise ValidationError({ - 'end_address': _( - "Ending address version (IPv{end_address_version}) does not match starting address " - "(IPv{start_address_version})" - ).format( - end_address_version=self.end_address.version, - start_address_version=self.start_address.version - ) + 'end_address': _("Starting and ending IP address versions must match") }) # Check that the start & end IP prefix lengths match if self.start_address.prefixlen != self.end_address.prefixlen: raise ValidationError({ - 'end_address': _( - "Ending address mask (/{end_address_prefixlen}) does not match starting address mask " - "(/{start_address_prefixlen})" - ).format( - end_address_prefixlen=self.end_address.prefixlen, - start_address_prefixlen=self.start_address.prefixlen - ) + 'end_address': _("Starting and ending IP address masks must match") }) # Check that the ending address is greater than the starting address diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index 12000f09d..f955c9cf8 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -51,10 +51,10 @@ {% trans "Total length" %} {% if total_length %} - {{ total_length|floatformat:"-2" }}{% if not is_definitive %}+{% endif %} {% trans "Meters" %} / - {{ total_length|meters_to_feet|floatformat:"-2" }} {% trans "Feet" %} + {{ total_length|floatformat:"-2" }}{% if not is_definitive %}+{% endif %} {% trans "Meters" %} / + {{ total_length|meters_to_feet|floatformat:"-2" }} {% trans "Feet" %} {% else %} - {% trans "N/A" %} + {{ ''|placeholder }} {% endif %} diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index ce00f333c..9b791d0e2 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -73,7 +73,7 @@ {% endif %} {% else %} - {% trans "N/A" %} + {{ ''|placeholder }} {% endif %} {% endwith %} diff --git a/netbox/templates/exceptions/import_error.html b/netbox/templates/exceptions/import_error.html index 70896328d..85803da0a 100644 --- a/netbox/templates/exceptions/import_error.html +++ b/netbox/templates/exceptions/import_error.html @@ -7,19 +7,20 @@

+ {% trans "Missing required packages" %}. {% blocktrans %} - Missing required packages. 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 compare the output to the list of - required packages. + 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 + compare the output to the list of required packages. {% endblocktrans %}

+ {% trans "WSGI service not restarted after upgrade" %}. {% blocktrans %} - WSGI service not restarted after upgrade. 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. + 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 %}

{% endblock message %} diff --git a/netbox/templates/exceptions/permission_error.html b/netbox/templates/exceptions/permission_error.html index 3df6ad5c8..334c3d0bd 100644 --- a/netbox/templates/exceptions/permission_error.html +++ b/netbox/templates/exceptions/permission_error.html @@ -7,10 +7,10 @@

+ {% trans "Insufficient write permission to the media root" %}. {% blocktrans with media_root=settings.MEDIA_ROOT %} - Insufficient write permission to the 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. + 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 %}

{% endblock message %} diff --git a/netbox/templates/exceptions/programming_error.html b/netbox/templates/exceptions/programming_error.html index 5d82e4511..d24378f7c 100644 --- a/netbox/templates/exceptions/programming_error.html +++ b/netbox/templates/exceptions/programming_error.html @@ -7,18 +7,18 @@

+ {% trans "Database migrations missing" %}. {% blocktrans %} - Database migrations missing. 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. + 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 %}

+ {% trans "Unsupported PostgreSQL version" %}. {% blocktrans %} - Unsupported PostgreSQL version. 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(). + 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 %}

{% endblock message %} diff --git a/netbox/templates/generic/bulk_import.html b/netbox/templates/generic/bulk_import.html index 08f13765c..f7d8aae77 100644 --- a/netbox/templates/generic/bulk_import.html +++ b/netbox/templates/generic/bulk_import.html @@ -177,7 +177,7 @@ Context: {% if field|widget_type == 'dateinput' %} {% trans "Format: YYYY-MM-DD" %} {% elif field|widget_type == 'checkboxinput' %} - {% trans "Specify \"true\" or \"false" %}" + {% trans "Specify true or false" %} {% endif %}