Skip to content

Commit b241c97

Browse files
Was added to searching support languages other than English for objec… (netbox-community#16706)
* Was added to searching support languages other than English for object types(s). * Fix SearchForm field label translation --------- Co-authored-by: Jeremy Stretch <[email protected]>
1 parent b605dfc commit b241c97

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

netbox/netbox/forms/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22

33
from django import forms
4-
from django.utils.translation import gettext as _
4+
from django.utils.translation import gettext_lazy as _
55

66
from netbox.search import LookupTypes
77
from netbox.search.backends import search_backend
@@ -36,7 +36,8 @@ class SearchForm(forms.Form):
3636
lookup = forms.ChoiceField(
3737
choices=LOOKUP_CHOICES,
3838
initial=LookupTypes.PARTIAL,
39-
required=False
39+
required=False,
40+
label=_('Lookup')
4041
)
4142

4243
def __init__(self, *args, **kwargs):

netbox/netbox/search/backends.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.db.models.functions import window
99
from django.db.models.signals import post_delete, post_save
1010
from django.utils.module_loading import import_string
11+
from django.utils.translation import gettext_lazy as _
1112
import netaddr
1213
from netaddr.core import AddrFormatError
1314

@@ -39,7 +40,7 @@ def get_object_types(self):
3940
# Organize choices by category
4041
categories = defaultdict(dict)
4142
for label, idx in registry['search'].items():
42-
categories[idx.get_category()][label] = title(idx.model._meta.verbose_name)
43+
categories[idx.get_category()][label] = _(title(idx.model._meta.verbose_name))
4344

4445
# Compile a nested tuple of choices for form rendering
4546
results = (

0 commit comments

Comments
 (0)