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:
Anton
2024-05-14 15:21:00 +02:00
committed by GitHub
parent a55a2bdaf1
commit d154e05937
5 changed files with 23 additions and 9 deletions

View File

@@ -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,

View File

@@ -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