Skip to content

Commit 08a419e

Browse files
arthansonjeremystretchkkthxbye-code
authored
11271 flag to disable localization (#11323)
* 11271 flag to disable localization * 11271 change to remove middleware * 11271 update docs for new var * Update docs/configuration/system.md Co-authored-by: kkthxbye <[email protected]> Co-authored-by: Jeremy Stretch <[email protected]> Co-authored-by: kkthxbye <[email protected]>
1 parent d417168 commit 08a419e

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

docs/configuration/system.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ Email is sent from NetBox only for critical events or if configured for [logging
6565

6666
---
6767

68+
## ENABLE_LOCALIZATION
69+
70+
Default: False
71+
72+
Determines if localization features are enabled or not. This should only be enabled for development or testing purposes as netbox is not yet fully localized. Turning this on will localize numeric and date formats (overriding what is set for DATE_FORMAT) based on the browser locale as well as translate certain strings from third party modules.
73+
74+
---
75+
6876
## HTTP_PROXIES
6977

7078
Default: None

netbox/netbox/configuration_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@
222222
# database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
223223
SESSION_FILE_PATH = None
224224

225+
# Localization
226+
ENABLE_LOCALIZATION = False
227+
225228
# Time zone (default: UTC)
226229
TIME_ZONE = 'UTC'
227230

netbox/netbox/settings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {})
138138
TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
139139
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
140+
ENABLE_LOCALIZATION = getattr(configuration, 'ENABLE_LOCALIZATION', False)
140141

141142
# Check for hard-coded dynamic config parameters
142143
for param in PARAMS:
@@ -356,6 +357,9 @@ def _setting(name, default=None):
356357
'django_prometheus.middleware.PrometheusAfterMiddleware',
357358
]
358359

360+
if not ENABLE_LOCALIZATION:
361+
MIDDLEWARE.remove("django.middleware.locale.LocaleMiddleware")
362+
359363
ROOT_URLCONF = 'netbox.urls'
360364

361365
TEMPLATES_DIR = BASE_DIR + '/templates'
@@ -651,6 +655,13 @@ def _setting(name, default=None):
651655
queue: RQ_PARAMS for queue in set(QUEUE_MAPPINGS.values()) if queue not in RQ_QUEUES
652656
})
653657

658+
#
659+
# Localization
660+
#
661+
662+
if not ENABLE_LOCALIZATION:
663+
USE_I18N = False
664+
USE_L10N = False
654665

655666
#
656667
# Plugins

0 commit comments

Comments
 (0)