diff --git a/docs/configuration/system.md b/docs/configuration/system.md index d0814bca6c..a1e0ebb17f 100644 --- a/docs/configuration/system.md +++ b/docs/configuration/system.md @@ -198,3 +198,11 @@ If `STORAGE_BACKEND` is not defined, this setting will be ignored. Default: UTC The time zone NetBox will use when dealing with dates and times. It is recommended to use UTC time unless you have a specific need to use a local time zone. Please see the [list of available time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + +--- + +## TRANSLATION_ENABLED + +Default: True + +Enables language translation for the user interface. (This parameter maps to Django's [USE_I18N](https://docs.djangoproject.com/en/stable/ref/settings/#std-setting-USE_I18N) setting.) diff --git a/netbox/netbox/preferences.py b/netbox/netbox/preferences.py index d560ef1ddd..d911aabb08 100644 --- a/netbox/netbox/preferences.py +++ b/netbox/netbox/preferences.py @@ -23,7 +23,7 @@ def get_page_lengths(): ), description=_('Enable dynamic UI navigation'), default=False, - experimental=True + warning=_('Experimental feature') ), 'locale.language': UserPreference( label=_('Language'), @@ -31,7 +31,12 @@ def get_page_lengths(): ('', _('Auto')), *settings.LANGUAGES, ), - description=_('Forces UI translation to the specified language.') + description=_('Forces UI translation to the specified language'), + warning=( + _("Support for translation has been disabled locally") + if not settings.TRANSLATION_ENABLED + else '' + ) ), 'pagination.per_page': UserPreference( label=_('Page length'), diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index b991c50293..4e9bf9c000 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -156,6 +156,7 @@ STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None) STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {}) TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC') +TRANSLATION_ENABLED = getattr(configuration, 'TRANSLATION_ENABLED', True) # Load any dynamic configuration parameters which have been hard-coded in the configuration file for param in CONFIG_PARAMS: @@ -445,6 +446,9 @@ def _setting(name, default=None): # Use timezone-aware datetime objects USE_TZ = True +# Toggle language translation support +USE_I18N = TRANSLATION_ENABLED + # 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 e5b9b612e7..7a9f63ea7f 100644 --- a/netbox/users/forms/model_forms.py +++ b/netbox/users/forms/model_forms.py @@ -40,11 +40,8 @@ def __new__(mcs, name, bases, attrs): 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 3eab4cb6e8..d7edf1f59c 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