diff --git a/netbox/netbox/preferences.py b/netbox/netbox/preferences.py index d560ef1dd..4978df40c 100644 --- a/netbox/netbox/preferences.py +++ b/netbox/netbox/preferences.py @@ -23,7 +23,7 @@ PREFERENCES = { ), description=_('Enable dynamic UI navigation'), default=False, - experimental=True + warning=_('Experimental feature') ), 'locale.language': UserPreference( label=_('Language'), @@ -31,7 +31,12 @@ PREFERENCES = { ('', _('Auto')), *settings.LANGUAGES, ), - description=_('Forces UI translation to the specified language.') + description=_('Forces UI translation to the specified language.'), + warning=( + f"Translation is globally disabled inside configuration.py" + if not settings.ENABLE_TRANSLATION + else '' + ) ), 'pagination.per_page': UserPreference( label=_('Page length'), diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 2aad6d114..3a3448105 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -92,6 +92,7 @@ DEVELOPER = getattr(configuration, 'DEVELOPER', False) DJANGO_ADMIN_ENABLED = getattr(configuration, 'DJANGO_ADMIN_ENABLED', False) DOCS_ROOT = getattr(configuration, 'DOCS_ROOT', os.path.join(os.path.dirname(BASE_DIR), 'docs')) EMAIL = getattr(configuration, 'EMAIL', {}) +ENABLE_TRANSLATION = getattr(configuration, 'ENABLE_TRANSLATION', True) EVENTS_PIPELINE = getattr(configuration, 'EVENTS_PIPELINE', ( 'extras.events.process_event_queue', )) @@ -156,7 +157,6 @@ SESSION_FILE_PATH = getattr(configuration, 'SESSION_FILE_PATH', None) STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None) STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {}) TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC') -USE_I18N = getattr(configuration, 'ENABLE_TRANSLATION', True) # Load any dynamic configuration parameters which have been hard-coded in the configuration file for param in CONFIG_PARAMS: @@ -446,6 +446,8 @@ LOGIN_REDIRECT_URL = f'/{BASE_PATH}' # Use timezone-aware datetime objects USE_TZ = True +USE_I18N = ENABLE_TRANSLATION + # WSGI WSGI_APPLICATION = 'netbox.wsgi.application' SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') diff --git a/netbox/users/forms/model_forms.py b/netbox/users/forms/model_forms.py index e5b9b612e..7a9f63ea7 100644 --- a/netbox/users/forms/model_forms.py +++ b/netbox/users/forms/model_forms.py @@ -40,11 +40,8 @@ class UserConfigFormMetaclass(forms.models.ModelFormMetaclass): help_text = f'{field_name}' if preference.description: help_text = f'{preference.description}
{help_text}' - if preference.experimental: - help_text = ( - f' Experimental feature
' - f'{help_text}' - ) + if warning := preference.warning: + help_text = f' {warning}
{help_text}' field_kwargs = { 'label': preference.label, 'choices': preference.choices, diff --git a/netbox/users/preferences.py b/netbox/users/preferences.py index 3eab4cb6e..d7edf1f59 100644 --- a/netbox/users/preferences.py +++ b/netbox/users/preferences.py @@ -2,10 +2,10 @@ class UserPreference: """ Represents a configurable user preference. """ - def __init__(self, label, choices, default=None, description='', coerce=lambda x: x, experimental=False): + def __init__(self, label, choices, default=None, description='', coerce=lambda x: x, warning=''): self.label = label self.choices = choices self.default = default if default is not None else choices[0] self.description = description self.coerce = coerce - self.experimental = experimental + self.warning = warning