15094 Add missing gettext to error strings for internationalization (#15155)

* 15049 add missing gettext to error strings

* 15049 add missing gettext to error strings

* 15094 review change

* 15094 review change

* Formatting cleanup

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
Arthur Hanson
2024-02-20 06:44:02 -08:00
committed by GitHub
parent 29f029d480
commit af27bf5eff
47 changed files with 275 additions and 133 deletions

View File

@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
from netaddr import AddrFormatError, IPAddress
from urllib.parse import urlparse
@@ -29,7 +30,7 @@ def get_client_ip(request, additional_headers=()):
return IPAddress(ip)
except AddrFormatError:
# We did our best
raise ValueError(f"Invalid IP address set for {header}: {ip}")
raise ValueError(_("Invalid IP address set for {header}: {ip}").format(header=header, ip=ip))
# Could not determine the client IP address from request headers
return None