From ed366c5ab2bfd5d044241438f6a3283ed87b9e9d Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 16 Dec 2022 08:56:14 -0500 Subject: [PATCH] Closes #11214: Introduce the DEFAULT_LANGUAGE configuration parameter --- docs/configuration/system.md | 11 +++++++++++ docs/release-notes/version-3.4.md | 1 + netbox/netbox/configuration_example.py | 3 +++ netbox/netbox/settings.py | 4 +--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/configuration/system.md b/docs/configuration/system.md index 3756b6a83..5a7c8bebd 100644 --- a/docs/configuration/system.md +++ b/docs/configuration/system.md @@ -12,6 +12,17 @@ BASE_PATH = 'netbox/' --- +## DEFAULT_LANGUAGE + +Default: `en-us` (US English) + +Defines the default preferred language/locale for requests that do not specify one. This is used to alter e.g. the display of dates and numbers to fit the user's locale. See [this list](http://www.i18nguy.com/unicode/language-identifiers.html) of standard language codes. (This parameter maps to Django's [`LANGUAGE_CODE`](https://docs.djangoproject.com/en/stable/ref/settings/#language-code) internal setting.) + +!!! note + Altering this parameter will *not* change the language used in NetBox. We hope to provide translation support in a future NetBox release. + +--- + ## DOCS_ROOT Default: `$INSTALL_ROOT/docs/` diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 8503ce8b4..32f46f1ef 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -5,6 +5,7 @@ ### Enhancements * [#9971](https://github.com/netbox-community/netbox/issues/9971) - Enable ordering of nested group models by name +* [#11214](https://github.com/netbox-community/netbox/issues/11214) - Introduce the `DEFAULT_LANGUAGE` configuration parameter ### Bug Fixes diff --git a/netbox/netbox/configuration_example.py b/netbox/netbox/configuration_example.py index 5e057d54a..f298b35fe 100644 --- a/netbox/netbox/configuration_example.py +++ b/netbox/netbox/configuration_example.py @@ -106,6 +106,9 @@ CORS_ORIGIN_REGEX_WHITELIST = [ # on a production system. DEBUG = False +# Set the default preferred language/locale +DEFAULT_LANGUAGE = 'en-us' + # Email settings EMAIL = { 'SERVER': 'localhost', diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 813d4bf01..47a3c14e9 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -94,6 +94,7 @@ FIELD_CHOICES = getattr(configuration, 'FIELD_CHOICES', {}) HTTP_PROXIES = getattr(configuration, 'HTTP_PROXIES', None) INTERNAL_IPS = getattr(configuration, 'INTERNAL_IPS', ('127.0.0.1', '::1')) JINJA2_FILTERS = getattr(configuration, 'JINJA2_FILTERS', {}) +LANGUAGE_CODE = getattr(configuration, 'DEFAULT_LANGUAGE', 'en-us') LOGGING = getattr(configuration, 'LOGGING', {}) LOGIN_PERSISTENCE = getattr(configuration, 'LOGIN_PERSISTENCE', False) LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False) @@ -386,9 +387,6 @@ AUTHENTICATION_BACKENDS = [ 'netbox.authentication.ObjectPermissionBackend', ] -# Internationalization -LANGUAGE_CODE = 'en-us' - # Time zones USE_TZ = True