Misc i18n cleanup

This commit is contained in:
Jeremy Stretch 2023-09-11 15:59:50 -04:00
parent 2ffa6d0188
commit 75b71890a4
15 changed files with 77 additions and 76 deletions

View File

@ -14,8 +14,8 @@ class DataSourceTypeChoices(ChoiceSet):
CHOICES = ( CHOICES = (
(LOCAL, _('Local'), 'gray'), (LOCAL, _('Local'), 'gray'),
(GIT, _('Git'), 'blue'), (GIT, 'Git', 'blue'),
(AMAZON_S3, _('Amazon S3'), 'blue'), (AMAZON_S3, 'Amazon S3', 'blue'),
) )

View File

@ -81,13 +81,13 @@ class GitBackend(DataBackend):
required=False, required=False,
label=_('Username'), label=_('Username'),
widget=forms.TextInput(attrs={'class': 'form-control'}), 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( 'password': forms.CharField(
required=False, required=False,
label=_('Password'), label=_('Password'),
widget=forms.TextInput(attrs={'class': 'form-control'}), 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( 'branch': forms.CharField(
required=False, required=False,

View File

@ -118,7 +118,9 @@ class SiteImportForm(NetBoxModelImportForm):
) )
help_texts = { help_texts = {
'time_zone': mark_safe( 'time_zone': mark_safe(
_('Time zone (<a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">available options</a>)') '{} (<a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">{}</a>)'.format(
_('Time zone'), _('available options')
)
) )
} }
@ -165,7 +167,7 @@ class RackRoleImportForm(NetBoxModelImportForm):
model = RackRole model = RackRole
fields = ('name', 'slug', 'color', 'description', 'tags') fields = ('name', 'slug', 'color', 'description', 'tags')
help_texts = { help_texts = {
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')), 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
} }
@ -375,7 +377,7 @@ class DeviceRoleImportForm(NetBoxModelImportForm):
model = DeviceRole model = DeviceRole
fields = ('name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags') fields = ('name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags')
help_texts = { help_texts = {
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')), 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
} }
@ -790,7 +792,9 @@ class InterfaceImportForm(NetBoxModelImportForm):
queryset=VirtualDeviceContext.objects.all(), queryset=VirtualDeviceContext.objects.all(),
required=False, required=False,
to_field_name='name', 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:') + ' <code>vdc1,vdc2,vdc3</code>'
)
) )
type = CSVChoiceField( type = CSVChoiceField(
label=_('Type'), label=_('Type'),
@ -1085,7 +1089,7 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm):
model = InventoryItemRole model = InventoryItemRole
fields = ('name', 'slug', 'color', 'description') fields = ('name', 'slug', 'color', 'description')
help_texts = { help_texts = {
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')), 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
} }
@ -1096,38 +1100,38 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm):
class CableImportForm(NetBoxModelImportForm): class CableImportForm(NetBoxModelImportForm):
# Termination A # Termination A
side_a_device = CSVModelChoiceField( side_a_device = CSVModelChoiceField(
label=_('Side a device'), label=_('Side A device'),
queryset=Device.objects.all(), queryset=Device.objects.all(),
to_field_name='name', to_field_name='name',
help_text=_('Side A device') help_text=_('Device name')
) )
side_a_type = CSVContentTypeField( side_a_type = CSVContentTypeField(
label=_('Side a type'), label=_('Side A type'),
queryset=ContentType.objects.all(), queryset=ContentType.objects.all(),
limit_choices_to=CABLE_TERMINATION_MODELS, limit_choices_to=CABLE_TERMINATION_MODELS,
help_text=_('Side A type') help_text=_('Termination type')
) )
side_a_name = forms.CharField( side_a_name = forms.CharField(
label=_('Side a name'), label=_('Side A name'),
help_text=_('Side A component name') help_text=_('Termination name')
) )
# Termination B # Termination B
side_b_device = CSVModelChoiceField( side_b_device = CSVModelChoiceField(
label=_('Side b device'), label=_('Side B device'),
queryset=Device.objects.all(), queryset=Device.objects.all(),
to_field_name='name', to_field_name='name',
help_text=_('Side B device') help_text=_('Device name')
) )
side_b_type = CSVContentTypeField( side_b_type = CSVContentTypeField(
label=_('Side b type'), label=_('Side B type'),
queryset=ContentType.objects.all(), queryset=ContentType.objects.all(),
limit_choices_to=CABLE_TERMINATION_MODELS, limit_choices_to=CABLE_TERMINATION_MODELS,
help_text=_('Side B type') help_text=_('Termination type')
) )
side_b_name = forms.CharField( side_b_name = forms.CharField(
label=_('Side b name'), label=_('Side B name'),
help_text=_('Side B component name') help_text=_('Termination name')
) )
# Cable attributes # Cable attributes
@ -1164,7 +1168,7 @@ class CableImportForm(NetBoxModelImportForm):
'status', 'tenant', 'label', 'color', 'length', 'length_unit', 'description', 'comments', 'tags', 'status', 'tenant', 'label', 'color', 'length', 'length_unit', 'description', 'comments', 'tags',
] ]
help_texts = { help_texts = {
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')), 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
} }
def _clean_side(self, side): def _clean_side(self, side):

View File

@ -799,9 +799,9 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
if self.bridge and self.bridge.device != self.device: if self.bridge and self.bridge.device != self.device:
if self.device.virtual_chassis is None: if self.device.virtual_chassis is None:
raise ValidationError({ raise ValidationError({
'bridge': _(""" 'bridge': _(
The selected bridge interface ({bridge}) belongs to a different device "The selected bridge interface ({bridge}) belongs to a different device ({device})."
({device}).""").format(bridge=self.bridge, device=self.bridge.device) ).format(bridge=self.bridge, device=self.bridge.device)
}) })
elif self.bridge.device.virtual_chassis != self.device.virtual_chassis: elif self.bridge.device.virtual_chassis != self.device.virtual_chassis:
raise ValidationError({ raise ValidationError({
@ -889,10 +889,10 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
# Validate untagged VLAN # Validate untagged VLAN
if self.untagged_vlan and self.untagged_vlan.site not in [self.device.site, None]: if self.untagged_vlan and self.untagged_vlan.site not in [self.device.site, None]:
raise ValidationError({ raise ValidationError({
'untagged_vlan': _(""" 'untagged_vlan': _(
The untagged VLAN ({untagged_vlan}) must belong to the same site as the "The untagged VLAN ({untagged_vlan}) must belong to the same site as the interface's parent "
interface's parent device, or it must be global. "device, or it must be global."
""").format(untagged_vlan=self.untagged_vlan) ).format(untagged_vlan=self.untagged_vlan)
}) })
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
@ -1067,9 +1067,10 @@ class RearPort(ModularComponentModel, CabledObjectModel, TrackingModelMixin):
frontport_count = self.frontports.count() frontport_count = self.frontports.count()
if self.positions < frontport_count: if self.positions < frontport_count:
raise ValidationError({ raise ValidationError({
"positions": _(""" "positions": _(
The number of positions cannot be less than the number of mapped front ports "The number of positions cannot be less than the number of mapped front ports "
({frontport_count})""").format(frontport_count=frontport_count) "({frontport_count})"
).format(frontport_count=frontport_count)
}) })

View File

@ -174,8 +174,13 @@ class PowerFeed(PrimaryModel, PathEndpoint, CabledObjectModel):
# Rack must belong to same Site as PowerPanel # Rack must belong to same Site as PowerPanel
if self.rack and self.rack.site != self.power_panel.site: if self.rack and self.rack.site != self.power_panel.site:
raise ValidationError(_("Rack {} ({}) and power panel {} ({}) are in different sites").format( raise ValidationError(_(
self.rack, self.rack.site, self.power_panel, self.power_panel.site "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 # AC voltage cannot be negative

View File

@ -164,7 +164,7 @@ class TagImportForm(CSVModelForm):
model = Tag model = Tag
fields = ('name', 'slug', 'color', 'description') fields = ('name', 'slug', 'color', 'description')
help_texts = { help_texts = {
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')), 'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
} }

View File

@ -4,6 +4,7 @@ from django import forms
from django.conf import settings from django.conf import settings
from django.db.models import Q from django.db.models import Q
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from core.forms.mixins import SyncedDataMixin from core.forms.mixins import SyncedDataMixin
@ -81,7 +82,8 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*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: if self.instance.pk:
self.fields['type'].disabled = True self.fields['type'].disabled = True
@ -90,10 +92,10 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm):
extra_choices = forms.CharField( extra_choices = forms.CharField(
widget=ChoicesWidget(), widget=ChoicesWidget(),
required=False, 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 ' '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:'
) ) + ' <code>choice1,First Choice</code>')
) )
class Meta: class Meta:

View File

@ -146,7 +146,7 @@ class ConfigContext(SyncedDataMixin, CloningMixin, ChangeLoggedModel):
# Verify that JSON data is provided as an object # Verify that JSON data is provided as an object
if type(self.data) is not dict: if type(self.data) is not dict:
raise ValidationError( 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): def sync_data(self):
@ -202,7 +202,7 @@ class ConfigContextModel(models.Model):
# Verify that JSON data is provided as an object # Verify that JSON data is provided as an object
if self.local_context_data and type(self.local_context_data) is not dict: if self.local_context_data and type(self.local_context_data) is not dict:
raise ValidationError( 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}'}
) )

View File

@ -554,25 +554,13 @@ class IPRange(PrimaryModel):
# Check that start & end IP versions match # Check that start & end IP versions match
if self.start_address.version != self.end_address.version: if self.start_address.version != self.end_address.version:
raise ValidationError({ raise ValidationError({
'end_address': _( 'end_address': _("Starting and ending IP address versions must match")
"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
)
}) })
# Check that the start & end IP prefix lengths match # Check that the start & end IP prefix lengths match
if self.start_address.prefixlen != self.end_address.prefixlen: if self.start_address.prefixlen != self.end_address.prefixlen:
raise ValidationError({ raise ValidationError({
'end_address': _( 'end_address': _("Starting and ending IP address masks must match")
"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
)
}) })
# Check that the ending address is greater than the starting address # Check that the ending address is greater than the starting address

View File

@ -54,7 +54,7 @@
{{ total_length|floatformat:"-2" }}{% if not is_definitive %}+{% endif %} {% trans "Meters" %} / {{ total_length|floatformat:"-2" }}{% if not is_definitive %}+{% endif %} {% trans "Meters" %} /
{{ total_length|meters_to_feet|floatformat:"-2" }} {% trans "Feet" %} {{ total_length|meters_to_feet|floatformat:"-2" }} {% trans "Feet" %}
{% else %} {% else %}
<span class="text-muted">{% trans "N/A" %}</span> {{ ''|placeholder }}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>

View File

@ -73,7 +73,7 @@
{% endif %} {% endif %}
</td> </td>
{% else %} {% else %}
<td class="text-muted">{% trans "N/A" %}</td> <td>{{ ''|placeholder }}</td>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
</tr> </tr>

View File

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

View File

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

View File

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

View File

@ -177,7 +177,7 @@ Context:
{% if field|widget_type == 'dateinput' %} {% if field|widget_type == 'dateinput' %}
<small class="text-muted">{% trans "Format: YYYY-MM-DD" %}</small> <small class="text-muted">{% trans "Format: YYYY-MM-DD" %}</small>
{% elif field|widget_type == 'checkboxinput' %} {% elif field|widget_type == 'checkboxinput' %}
<small class="text-muted">{% trans "Specify \"true\" or \"false" %}"</small> <small class="text-muted">{% trans "Specify true or false" %}</small>
{% endif %} {% endif %}
</td> </td>
</tr> </tr>