Opened 7 years ago

Closed 7 years ago

#27735 closed Cleanup/optimization (fixed)

l10n is applied to Select widget's choices after template-based widget rendering

Reported by: David Szotten Owned by: nobody
Component: Documentation Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


While trying to update django-crispy-forms to django master (1.11) i came across the following:

on 1.10,
Select (and e.g. RadioSelect, CheckboxSelectMultiple) don't seem to localise labels, but with template based widget rendering they do

(compare the output before and after template based widget rendering (e.g. 1.10 vs current master)

    settings.USE_L10N = True
    settings.USE_THOUSAND_SEPARATOR = True
    print forms.RadioSelect(choices=[(1000, 1000)]).render('foo', '1000')

    # master
    <option value="1000" selected>1,000</option>

    # 1.10
    <option value="1000" selected="selected">1000</option>

I've not been able to find documentation (my search-fu might be failing me) about either behaviour, (nor am i a user of l10n so i'm not sure which of these behaviours is more "correct")

so my question is: is this a regression? a bugfix?

(in django-crispy-forms seems to choose its behaviour to match django, and adds explicit tests for the old behaviour)


Change History (6)

comment:1 by Claude Paroz, 7 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Accepted as I think something has to be done, either documentation or a fix.

I would be tempted to document this as a backwards incompatibility, as localizing the label (not the value) would be consistent with the rest of Django template rendering. However, there should be a not too hard way of reverting that behavior. If there is not, we might have to keep the old behavior for now.

comment:2 by Tim Graham, 7 years ago

Component: FormsDocumentation
Has patch: set
Summary: l10n change for Select widgetl10n is applied to Select widget's choices after template-based widget rendering
Type: UncategorizedCleanup/optimization

Overriding django/forms/templates/django/forms/widgets/input_option.html and wrapping {{ widget.label }} with {% localize off %} is a possibility to revert to the old behavior. PR to update the 1.11 release notes.

comment:3 by Claude Paroz, 7 years ago

I'm fine with Tim's proposal to document the change in the release notes. David, any opinion?

comment:4 by David Szotten, 7 years ago

as i mentioned, i'm afraid i don't make use of these features (nor am i fully aware of the internals/details of crispy-forms that make use of them)

i just wanted to highlight the undocumented change

Tim's proposal seems fine with me (not yet had a chance to check if it's enough to fix crispy-forms but not sure that should matter) though it might be good to get input from someone more familiar with l10n (that someone may be you Tim / Claude)

comment:5 by Claude Paroz, 7 years ago

Triage Stage: AcceptedReady for checkin

I think we should follow the rule: "if L10N is true, always localize unless the programmer asks not to".

comment:6 by GitHub <noreply@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 0f46bc67:

Fixed #27735 -- Doc'd form widget l10n change (refs #15667).

Note: See TracTickets for help on using tickets.
Back to Top