mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 04:56:29 -06:00
Was added to searching support languages other than English for objec… (#16706)
* Was added to searching support languages other than English for object types(s). * Fix SearchForm field label translation --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
b605dfcba0
commit
b241c97e00
@ -1,7 +1,7 @@
|
||||
import re
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.search import LookupTypes
|
||||
from netbox.search.backends import search_backend
|
||||
@ -36,7 +36,8 @@ class SearchForm(forms.Form):
|
||||
lookup = forms.ChoiceField(
|
||||
choices=LOOKUP_CHOICES,
|
||||
initial=LookupTypes.PARTIAL,
|
||||
required=False
|
||||
required=False,
|
||||
label=_('Lookup')
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -8,6 +8,7 @@ from django.db.models.fields.related import ForeignKey
|
||||
from django.db.models.functions import window
|
||||
from django.db.models.signals import post_delete, post_save
|
||||
from django.utils.module_loading import import_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
import netaddr
|
||||
from netaddr.core import AddrFormatError
|
||||
|
||||
@ -39,7 +40,7 @@ class SearchBackend:
|
||||
# Organize choices by category
|
||||
categories = defaultdict(dict)
|
||||
for label, idx in registry['search'].items():
|
||||
categories[idx.get_category()][label] = title(idx.model._meta.verbose_name)
|
||||
categories[idx.get_category()][label] = _(title(idx.model._meta.verbose_name))
|
||||
|
||||
# Compile a nested tuple of choices for form rendering
|
||||
results = (
|
||||
|
Loading…
Reference in New Issue
Block a user