Просмотр исходного кода

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 <400797+kkthxbye-code@users.noreply.github.com>

Co-authored-by: Jeremy Stretch <jstretch@ns1.com>
Co-authored-by: kkthxbye <400797+kkthxbye-code@users.noreply.github.com>
Arthur Hanson 3 лет назад
Родитель
Сommit
08a419ec7a
3 измененных файлов с 22 добавлено и 0 удалено
  1. 8 0
      docs/configuration/system.md
  2. 3 0
      netbox/netbox/configuration_example.py
  3. 11 0
      netbox/netbox/settings.py

+ 8 - 0
docs/configuration/system.md

@@ -65,6 +65,14 @@ Email is sent from NetBox only for critical events or if configured for [logging
 
 
 ---
 ---
 
 
+## ENABLE_LOCALIZATION
+
+Default: False
+
+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.
+
+---
+
 ## HTTP_PROXIES
 ## HTTP_PROXIES
 
 
 Default: None
 Default: None

+ 3 - 0
netbox/netbox/configuration_example.py

@@ -222,6 +222,9 @@ SESSION_COOKIE_NAME = 'sessionid'
 # database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
 # database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
 SESSION_FILE_PATH = None
 SESSION_FILE_PATH = None
 
 
+# Localization
+ENABLE_LOCALIZATION = False
+
 # Time zone (default: UTC)
 # Time zone (default: UTC)
 TIME_ZONE = 'UTC'
 TIME_ZONE = 'UTC'
 
 

+ 11 - 0
netbox/netbox/settings.py

@@ -137,6 +137,7 @@ STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None)
 STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {})
 STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {})
 TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
 TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
 TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
 TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
+ENABLE_LOCALIZATION = getattr(configuration, 'ENABLE_LOCALIZATION', False)
 
 
 # Check for hard-coded dynamic config parameters
 # Check for hard-coded dynamic config parameters
 for param in PARAMS:
 for param in PARAMS:
@@ -356,6 +357,9 @@ MIDDLEWARE = [
     'django_prometheus.middleware.PrometheusAfterMiddleware',
     'django_prometheus.middleware.PrometheusAfterMiddleware',
 ]
 ]
 
 
+if not ENABLE_LOCALIZATION:
+    MIDDLEWARE.remove("django.middleware.locale.LocaleMiddleware")
+
 ROOT_URLCONF = 'netbox.urls'
 ROOT_URLCONF = 'netbox.urls'
 
 
 TEMPLATES_DIR = BASE_DIR + '/templates'
 TEMPLATES_DIR = BASE_DIR + '/templates'
@@ -651,6 +655,13 @@ RQ_QUEUES.update({
     queue: RQ_PARAMS for queue in set(QUEUE_MAPPINGS.values()) if queue not in RQ_QUEUES
     queue: RQ_PARAMS for queue in set(QUEUE_MAPPINGS.values()) if queue not in RQ_QUEUES
 })
 })
 
 
+#
+# Localization
+#
+
+if not ENABLE_LOCALIZATION:
+    USE_I18N = False
+    USE_L10N = False
 
 
 #
 #
 # Plugins
 # Plugins