mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 16:06:43 -06:00
Translations cleanup
This commit is contained in:
parent
30ce9edf1c
commit
701870d919
@ -80,10 +80,10 @@ class RackWidthChoices(ChoiceSet):
|
||||
WIDTH_23IN = 23
|
||||
|
||||
CHOICES = (
|
||||
(WIDTH_10IN, _('10 inches')),
|
||||
(WIDTH_19IN, _('19 inches')),
|
||||
(WIDTH_21IN, _('21 inches')),
|
||||
(WIDTH_23IN, _('23 inches')),
|
||||
(WIDTH_10IN, _('{n} inches').format(n=10)),
|
||||
(WIDTH_19IN, _('{n} inches').format(n=19)),
|
||||
(WIDTH_21IN, _('{n} inches').format(n=21)),
|
||||
(WIDTH_23IN, _('{n} inches').format(n=23)),
|
||||
)
|
||||
|
||||
|
||||
|
@ -534,14 +534,16 @@ class FrontPortTemplate(ModularComponentTemplateModel):
|
||||
# Validate rear port assignment
|
||||
if self.rear_port.device_type != self.device_type:
|
||||
raise ValidationError(
|
||||
_("Rear port ({}) must belong to the same device type").format(self.rear_port)
|
||||
_("Rear port ({name}) must belong to the same device type").format(name=self.rear_port)
|
||||
)
|
||||
|
||||
# Validate rear port position assignment
|
||||
if self.rear_port_position > self.rear_port.positions:
|
||||
raise ValidationError(
|
||||
_("Invalid rear port position ({}); rear port {} has only {} positions").format(
|
||||
self.rear_port_position, self.rear_port.name, self.rear_port.positions
|
||||
_("Invalid rear port position ({position}); rear port {name} has only {count} positions").format(
|
||||
position=self.rear_port_position,
|
||||
name=self.rear_port.name,
|
||||
count=self.rear_port.positions
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -302,8 +302,13 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
||||
)
|
||||
if d.position not in u_available:
|
||||
raise ValidationError({
|
||||
'u_height': _("Device {} in rack {} does not have sufficient space to accommodate a height of "
|
||||
"{}U").format(d, d.rack, self.u_height)
|
||||
'u_height': _(
|
||||
"Device {device} in rack {rack} does not have sufficient space to accommodate a "
|
||||
"height of {height}U"
|
||||
).format(
|
||||
device=d,
|
||||
rack=d.rack,
|
||||
height=self.u_height)
|
||||
})
|
||||
|
||||
# If modifying the height of an existing DeviceType to 0U, check for any instances assigned to a rack position.
|
||||
|
@ -562,9 +562,9 @@ class RackReservation(PrimaryModel):
|
||||
invalid_units = [u for u in self.units if u not in self.rack.units]
|
||||
if invalid_units:
|
||||
raise ValidationError({
|
||||
'units': _("Invalid unit(s) for {}U rack: {}").format(
|
||||
self.rack.u_height,
|
||||
', '.join([str(u) for u in invalid_units]),
|
||||
'units': _("Invalid unit(s) for {height}U rack: {unit_list}").format(
|
||||
height=self.rack.u_height,
|
||||
unit_list=', '.join([str(u) for u in invalid_units])
|
||||
),
|
||||
})
|
||||
|
||||
@ -575,8 +575,8 @@ class RackReservation(PrimaryModel):
|
||||
conflicting_units = [u for u in self.units if u in reserved_units]
|
||||
if conflicting_units:
|
||||
raise ValidationError({
|
||||
'units': _('The following units have already been reserved: {}').format(
|
||||
', '.join([str(u) for u in conflicting_units]),
|
||||
'units': _('The following units have already been reserved: {unit_list}').format(
|
||||
unit_list=', '.join([str(u) for u in conflicting_units])
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -140,8 +140,11 @@ class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
|
||||
if covering_aggregates:
|
||||
raise ValidationError({
|
||||
'prefix': _(
|
||||
"Aggregates cannot overlap. {} is already covered by an existing aggregate ({})."
|
||||
).format(self.prefix, covering_aggregates[0])
|
||||
"Aggregates cannot overlap. {prefix} is already covered by an existing aggregate ({aggregate})."
|
||||
).format(
|
||||
prefix=self.prefix,
|
||||
aggregate=covering_aggregates[0]
|
||||
)
|
||||
})
|
||||
|
||||
# Ensure that the aggregate being added does not cover an existing aggregate
|
||||
@ -150,8 +153,11 @@ class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
|
||||
covered_aggregates = covered_aggregates.exclude(pk=self.pk)
|
||||
if covered_aggregates:
|
||||
raise ValidationError({
|
||||
'prefix': _("Aggregates cannot overlap. {} covers an existing aggregate ({}).").format(
|
||||
self.prefix, covered_aggregates[0]
|
||||
'prefix': _(
|
||||
"Prefixes cannot overlap aggregates. {prefix} covers an existing aggregate ({aggregate})."
|
||||
).format(
|
||||
prefix=self.prefix,
|
||||
aggregate=covered_aggregates[0]
|
||||
)
|
||||
})
|
||||
|
||||
@ -314,10 +320,11 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
|
||||
if (self.vrf is None and get_config().ENFORCE_GLOBAL_UNIQUE) or (self.vrf and self.vrf.enforce_unique):
|
||||
duplicate_prefixes = self.get_duplicates()
|
||||
if duplicate_prefixes:
|
||||
table = _("VRF {vrf}").format(vrf=self.vrf) if self.vrf else _("global table")
|
||||
raise ValidationError({
|
||||
'prefix': _("Duplicate prefix found in {}: {}").format(
|
||||
_("VRF {}").format(self.vrf) if self.vrf else _("global table"),
|
||||
duplicate_prefixes.first(),
|
||||
'prefix': _("Duplicate prefix found in {table}: {prefix}").format(
|
||||
table=table,
|
||||
prefix=duplicate_prefixes.first(),
|
||||
)
|
||||
})
|
||||
|
||||
@ -843,10 +850,11 @@ class IPAddress(PrimaryModel):
|
||||
self.role not in IPADDRESS_ROLES_NONUNIQUE or
|
||||
any(dip.role not in IPADDRESS_ROLES_NONUNIQUE for dip in duplicate_ips)
|
||||
):
|
||||
table = _("VRF {}").format(self.vrf) if self.vrf else _("global table")
|
||||
raise ValidationError({
|
||||
'address': _("Duplicate IP address found in {}: {}").format(
|
||||
_("VRF {}").format(self.vrf) if self.vrf else _("global table"),
|
||||
duplicate_ips.first(),
|
||||
'address': _("Duplicate IP address found in {table}: {ipaddress}").format(
|
||||
table=table,
|
||||
ipaddress=duplicate_ips.first(),
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.registry import registry
|
||||
from utilities.choices import ButtonColorChoices
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
{% block message %}
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Are you sure you want to delete this device bay from <strong>{{ devicebay.device }}</strong>?
|
||||
{% blocktrans trimmed with device=devicebay.device %}
|
||||
Are you sure you want to delete this device bay from <strong>{{ device }}</strong>?
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
@ -151,8 +151,12 @@ class ClusterAddDevicesForm(BootstrapMixin, forms.Form):
|
||||
for device in self.cleaned_data.get('devices', []):
|
||||
if device.site != self.cluster.site:
|
||||
raise ValidationError({
|
||||
'devices': _("{} belongs to a different site ({}) than the cluster ({})").format(
|
||||
device, device.site, self.cluster.site
|
||||
'devices': _(
|
||||
"{device} belongs to a different site ({site}) than the cluster ({cluster_site})"
|
||||
).format(
|
||||
device=device,
|
||||
site=device.site,
|
||||
cluster_site=self.cluster.site
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -138,7 +138,10 @@ class Cluster(ContactsMixin, PrimaryModel):
|
||||
nonsite_devices = Device.objects.filter(cluster=self).exclude(site=self.site).count()
|
||||
if nonsite_devices:
|
||||
raise ValidationError({
|
||||
'site': _("{} devices are assigned as hosts for this cluster but are not in site {}").format(
|
||||
nonsite_devices, self.site
|
||||
'site': _(
|
||||
"{count} devices are assigned as hosts for this cluster but are not in site {site}"
|
||||
).format(
|
||||
count=nonsite_devices,
|
||||
site=self.site
|
||||
)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user