Issues relating to the enabling of localization and LocaleMiddleware #7397

Closed
opened 2025-12-29 20:22:56 +01:00 by adam · 1 comment
Owner

Originally created by @kkthxbye-code on GitHub (Dec 21, 2022).

Originally assigned to: @arthanson on GitHub.

NetBox version

v3.4.1

Python version

3.11

Steps to Reproduce

This issue is intended to track all the issues related to the enabling of USE_L10N and LocaleMiddleware.

Some words are now translated, causing a mix of English and the browser language

https://github.com/netbox-community/netbox/issues/11189#issuecomment-1356326763 - Humanized dates are output with localized minutes/hours/days
https://github.com/netbox-community/netbox/issues/11240 - The word "Tags" is displayed as the German word "Schlagwörter"

Possible solution is to disable USE_I18N as netbox is not yet translated itself.

Floats are output with localized decimal separator breaking progress bars and other functionality

https://github.com/netbox-community/netbox/issues/11272 - Device position dropdown gets the U value with a comma, causing device save to fail.

https://github.com/netbox-community/netbox/discussions/11270 - When browser language is set to any language using comma as a decimal separator it breaks the progressbars:

https://github.com/netbox-community/netbox/issues/11273
3675ad2539/netbox/utilities/templates/helpers/utilization_graph.html (L6)

HTML doesn't support commas there for displaying progressbars. Possible solution is to disable the LocaleMiddleware again until we have a better understanding of the effects. Alternatively find all the places where comma as a decimal separator is invalid and find a way to output the unlocalized float.

It is not possible to configure the date and datetime format anymore

https://github.com/netbox-community/netbox/issues/11189#issuecomment-1356326763
https://github.com/netbox-community/netbox/issues/11268

The way to configuring a global date and datetime format with LocaleMiddleware installed seems to be the following:
https://docs.djangoproject.com/en/4.1/ref/settings/#format-module-path

Currently we do not expose this and frankly I think it's a bad UX to have to create formats.py for each language you want to control localization for. It is also not great for people running containerized as it forces either mounts or building a custom image. Maybe there's a better way I'm missing. My suggestion is to revert the USE_L10N and LocaleMiddleware changes until we have a better solution for all the above problems. Django 5 is not slated to come out until december 2023, so we have plenty of time. Currently I do not see any benefits to the changes.

An alternative to reverting would be allowing the disabling of the LocaleMiddleware by a netbox setting.

Originally created by @kkthxbye-code on GitHub (Dec 21, 2022). Originally assigned to: @arthanson on GitHub. ### NetBox version v3.4.1 ### Python version 3.11 ### Steps to Reproduce This issue is intended to track all the issues related to the enabling of USE_L10N and LocaleMiddleware. ### Some words are now translated, causing a mix of English and the browser language https://github.com/netbox-community/netbox/issues/11189#issuecomment-1356326763 - Humanized dates are output with localized `minutes/hours/days` https://github.com/netbox-community/netbox/issues/11240 - The word "Tags" is displayed as the German word "Schlagwörter" Possible solution is to disable USE_I18N as netbox is not yet translated itself. ### Floats are output with localized decimal separator breaking progress bars and other functionality https://github.com/netbox-community/netbox/issues/11272 - Device position dropdown gets the U value with a comma, causing device save to fail. https://github.com/netbox-community/netbox/discussions/11270 - When browser language is set to any language using comma as a decimal separator it breaks the progressbars: https://github.com/netbox-community/netbox/issues/11273 https://github.com/netbox-community/netbox/blob/3675ad2539400038af6797140ddca3679b8bca30/netbox/utilities/templates/helpers/utilization_graph.html#L6 HTML doesn't support commas there for displaying progressbars. Possible solution is to disable the LocaleMiddleware again until we have a better understanding of the effects. Alternatively find all the places where comma as a decimal separator is invalid and find a way to output the unlocalized float. ### It is not possible to configure the date and datetime format anymore https://github.com/netbox-community/netbox/issues/11189#issuecomment-1356326763 https://github.com/netbox-community/netbox/issues/11268 The way to configuring a global date and datetime format with LocaleMiddleware installed seems to be the following: https://docs.djangoproject.com/en/4.1/ref/settings/#format-module-path Currently we do not expose this and frankly I think it's a bad UX to have to create formats.py for each language you want to control localization for. It is also not great for people running containerized as it forces either mounts or building a custom image. Maybe there's a better way I'm missing. My suggestion is to revert the `USE_L10N` and `LocaleMiddleware` changes until we have a better solution for all the above problems. Django 5 is not slated to come out until december 2023, so we have plenty of time. Currently I do not see any benefits to the changes. An alternative to reverting would be allowing the disabling of the `LocaleMiddleware` by a netbox setting.
adam added the type: bugstatus: accepted labels 2025-12-29 20:22:56 +01:00
adam closed this issue 2025-12-29 20:22:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 22, 2022):

An alternative to reverting would be allowing the disabling of the LocaleMiddleware by a netbox setting.

IMO this might be the best solution for now. We can introduce a configuration parameter to toggle localization (defaulting to disabled) rather than forcing it to enabled. This will allow us to continue testing localization support until it becomes a mandatory component of the Django framework.

@jeremystretch commented on GitHub (Dec 22, 2022): > An alternative to reverting would be allowing the disabling of the LocaleMiddleware by a netbox setting. IMO this might be the best solution for now. We can introduce a configuration parameter to toggle localization (defaulting to disabled) rather than forcing it to enabled. This will allow us to continue testing localization support until it becomes a mandatory component of the Django framework.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7397