mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 19:32:24 -06:00
add ENABLE_TRANSLATION setting to optionally turn translation off (#16096)
* add USE_I18N setting * change setting name to ENABLE_TRANSLATION * raise a warning in the UI when translation is disabled * Misc cleanup * Rename to TRANSLATION_ENABLED for consistency with other settings --------- Co-authored-by: Anton Myasnikov <anton.myasnikov@nordigy.ru> Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@@ -40,11 +40,8 @@ class UserConfigFormMetaclass(forms.models.ModelFormMetaclass):
|
||||
help_text = f'<code>{field_name}</code>'
|
||||
if preference.description:
|
||||
help_text = f'{preference.description}<br />{help_text}'
|
||||
if preference.experimental:
|
||||
help_text = (
|
||||
f'<span class="text-danger"><i class="mdi mdi-alert"></i> Experimental feature</span><br />'
|
||||
f'{help_text}'
|
||||
)
|
||||
if warning := preference.warning:
|
||||
help_text = f'<span class="text-danger"><i class="mdi mdi-alert"></i> {warning}</span><br />{help_text}'
|
||||
field_kwargs = {
|
||||
'label': preference.label,
|
||||
'choices': preference.choices,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user