Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #14141: translation cleanup #14143

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions netbox/circuits/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ class CircuitFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilte
provider_account_id = django_filters.ModelMultipleChoiceFilter(
field_name='provider_account',
queryset=ProviderAccount.objects.all(),
label=_('ProviderAccount (ID)'),
label=_('Provider account (ID)'),
)
provider_network_id = django_filters.ModelMultipleChoiceFilter(
field_name='terminations__provider_network',
queryset=ProviderNetwork.objects.all(),
label=_('ProviderNetwork (ID)'),
label=_('Provider network (ID)'),
)
type_id = django_filters.ModelMultipleChoiceFilter(
queryset=CircuitType.objects.all(),
Expand Down
2 changes: 1 addition & 1 deletion netbox/circuits/forms/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ProviderNetworkFilterForm(NetBoxModelFilterSetForm):
label=_('Provider')
)
service_id = forms.CharField(
label=_('Service id'),
label=_('Service ID'),
max_length=100,
required=False
)
Expand Down
8 changes: 4 additions & 4 deletions netbox/dcim/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
)


Expand Down
12 changes: 6 additions & 6 deletions netbox/dcim/forms/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ def clean(self):
# It is not possible to adopt components already belonging to a module
if adopt_components and existing_item and existing_item.module:
raise forms.ValidationError(
_("Cannot adopt {name} '{resolved_name}' as it already belongs to a module").format(
name=template.component_model.__name__,
resolved_name=resolved_name
_("Cannot adopt {model} {name} as it already belongs to a module").format(
model=template.component_model.__name__,
name=resolved_name
)
)

# If we are not adopting components we error if the component exists
if not adopt_components and resolved_name in installed_components:
raise forms.ValidationError(
_("{name} - {resolved_name} already exists").format(
name=template.component_model.__name__,
resolved_name=resolved_name
_("A {model} named {name} already exists").format(
model=template.component_model.__name__,
name=resolved_name
)
)
8 changes: 5 additions & 3 deletions netbox/dcim/models/device_component_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,16 @@ def clean(self):
# 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
)
)

Expand Down
30 changes: 17 additions & 13 deletions netbox/dcim/models/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ def clean(self):
)
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.
Expand Down Expand Up @@ -920,7 +922,7 @@ def clean(self):
if self.primary_ip4:
if self.primary_ip4.family != 4:
raise ValidationError({
'primary_ip4': _("{primary_ip4} is not an IPv4 address.").format(primary_ip4=self.primary_ip4)
'primary_ip4': _("{ip} is not an IPv4 address.").format(ip=self.primary_ip4)
})
if self.primary_ip4.assigned_object in vc_interfaces:
pass
Expand All @@ -929,13 +931,13 @@ def clean(self):
else:
raise ValidationError({
'primary_ip4': _(
"The specified IP address ({primary_ip4}) is not assigned to this device."
).format(primary_ip4=self.primary_ip4)
"The specified IP address ({ip}) is not assigned to this device."
).format(ip=self.primary_ip4)
})
if self.primary_ip6:
if self.primary_ip6.family != 6:
raise ValidationError({
'primary_ip6': _("{primary_ip6} is not an IPv6 address.").format(primary_ip6=self.primary_ip6m)
'primary_ip6': _("{ip} is not an IPv6 address.").format(ip=self.primary_ip6)
})
if self.primary_ip6.assigned_object in vc_interfaces:
pass
Expand All @@ -944,8 +946,8 @@ def clean(self):
else:
raise ValidationError({
'primary_ip6': _(
"The specified IP address ({primary_ip6}) is not assigned to this device."
).format(primary_ip6=self.primary_ip6)
"The specified IP address ({ip}) is not assigned to this device."
).format(ip=self.primary_ip6)
})
if self.oob_ip:
if self.oob_ip.assigned_object in vc_interfaces:
Expand All @@ -963,17 +965,19 @@ def clean(self):
raise ValidationError({
'platform': _(
"The assigned platform is limited to {platform_manufacturer} device types, but this device's "
"type belongs to {device_type_manufacturer}."
"type belongs to {devicetype_manufacturer}."
).format(
platform_manufacturer=self.platform.manufacturer,
device_type_manufacturer=self.device_type.manufacturer
devicetype_manufacturer=self.device_type.manufacturer
)
})

# A Device can only be assigned to a Cluster in the same Site (or no Site)
if self.cluster and self.cluster.site is not None and self.cluster.site != self.site:
raise ValidationError({
'cluster': _("The assigned cluster belongs to a different site ({})").format(self.cluster.site)
'cluster': _("The assigned cluster belongs to a different site ({site})").format(
site=self.cluster.site
)
})

# Validate virtual chassis assignment
Expand Down Expand Up @@ -1445,8 +1449,8 @@ def clean(self):
if primary_ip.family != family:
raise ValidationError({
f'primary_ip{family}': _(
"{primary_ip} is not an IPv{family} address."
).format(family=family, primary_ip=primary_ip)
"{ip} is not an IPv{family} address."
).format(family=family, ip=primary_ip)
})
device_interfaces = self.device.vc_interfaces(if_master=False)
if primary_ip.assigned_object not in device_interfaces:
Expand Down
10 changes: 5 additions & 5 deletions netbox/dcim/models/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ def clean(self):
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])
),
})

Expand All @@ -575,8 +575,8 @@ def clean(self):
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])
)
})

Expand Down
8 changes: 4 additions & 4 deletions netbox/extras/models/customfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ def clean(self):
except ValidationError as err:
raise ValidationError({
'default': _(
'Invalid default value "{default}": {message}'
).format(default=self.default, message=err.message)
'Invalid default value "{value}": {error}'
).format(value=self.default, error=err.message)
})

# Minimum/maximum values can be set only for numeric fields
Expand Down Expand Up @@ -332,8 +332,8 @@ def clean(self):
elif self.object_type:
raise ValidationError({
'object_type': _(
"{type_display} fields may not define an object type.")
.format(type_display=self.get_type_display())
"{type} fields may not define an object type.")
.format(type=self.get_type_display())
})

def serialize(self, value):
Expand Down
6 changes: 3 additions & 3 deletions netbox/ipam/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,14 @@ def clean(self):
# Do not allow assigning a network ID or broadcast address to an interface.
if interface and (address := self.cleaned_data.get('address')):
if address.ip == address.network:
msg = _("{address} is a network ID, which may not be assigned to an interface.").format(address=address)
msg = _("{ip} is a network ID, which may not be assigned to an interface.").format(ip=address.ip)
if address.version == 4 and address.prefixlen not in (31, 32):
raise ValidationError(msg)
if address.version == 6 and address.prefixlen not in (127, 128):
raise ValidationError(msg)
if address.version == 4 and address.ip == address.broadcast and address.prefixlen not in (31, 32):
msg = _("{address} is a broadcast address, which may not be assigned to an interface.").format(
address=address
msg = _("{ip} is a broadcast address, which may not be assigned to an interface.").format(
ip=address.ip
)
raise ValidationError(msg)

Expand Down
28 changes: 18 additions & 10 deletions netbox/ipam/models/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ def clean(self):
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
Expand All @@ -150,8 +153,11 @@ def clean(self):
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]
)
})

Expand Down Expand Up @@ -314,10 +320,11 @@ def clean(self):
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(),
)
})

Expand Down Expand Up @@ -843,10 +850,11 @@ def clean(self):
self.role not in IPADDRESS_ROLES_NONUNIQUE or
any(dip.role not in IPADDRESS_ROLES_NONUNIQUE for dip in duplicate_ips)
):
table = _("VRF {vrf}").format(vrf=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(),
)
})

Expand Down
4 changes: 2 additions & 2 deletions netbox/ipam/models/vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def clean(self):
if self.group and not self.group.min_vid <= self.vid <= self.group.max_vid:
raise ValidationError({
'vid': _(
"VID must be between {min_vid} and {max_vid} for VLANs in group {group}"
).format(min_vid=self.group.min_vid, max_vid=self.group.max_vid, group=self.group)
"VID must be between {minimum} and {maximum} for VLANs in group {group}"
).format(minimum=self.group.min_vid, maximum=self.group.max_vid, group=self.group)
})

def get_status_color(self):
Expand Down
2 changes: 1 addition & 1 deletion netbox/netbox/navigation/menu.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions netbox/templates/dcim/devicebay_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Loading