Opened 7 years ago
Last modified 4 years ago
#30086 closed Cleanup/optimization
The numberformat template filter does not respect local localization settings — at Initial Version
| Reported by: | Meiyer | Owned by: | nobody |
|---|---|---|---|
| Component: | Template system | Version: | 1.11 |
| Severity: | Normal | Keywords: | |
| Cc: | Florian Demmer, Carsten Fuchs | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Specifically, when the filter is used within the {% localize [on|off] %} block with the localization setting opposed to the value of USE_L10N ('on' when USE_L10N = False or 'off' when USE_L10N = True), the localization setting has not effect.
This is due to the use of formats.number_format() without its use_l10n parameter, by the numberformat template filter (e.g. https://github.com/django/django/blob/master/django/template/defaultfilters.py#L144, https://github.com/django/django/blob/master/django/template/defaultfilters.py#L163). The value of the use_l10n parameter shall be taken out of the template rendering context. But I do not see any easy solution to this, as filters do not take context...