Opened 13 years ago

Closed 2 years ago

#14586 closed Cleanup/optimization (invalid)

Make interpolate JS function not require the named parameter.

Reported by: Amin Mirzaee Owned by: nobody
Component: Internationalization Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It is completely unnecessary and annoying to have to specify an additional parameter in Javascript
when using a dictionary to fill in the strings. Switching back and forth between python and js, this
can be often times forgotton, with bad results.

With this fix, compatibility is maintained with all current utilizations.

Attachments (1)

interpolate_mod.diff (583 bytes ) - added by Amin Mirzaee 13 years ago.

Download all attachments as: .zip

Change History (9)

by Amin Mirzaee, 13 years ago

Attachment: interpolate_mod.diff added

comment:1 by Claude Paroz, 13 years ago

Component: TranslationsInternationalization

comment:2 by Julien Phalip, 13 years ago

milestone: 1.3
Triage Stage: UnreviewedDesign decision needed

Making this change would likely break backwards compatibility. Needs more design discussion.

comment:3 by Julien Phalip, 13 years ago

Severity: Normal
Type: Cleanup/optimization

comment:4 by anonymous, 12 years ago

Easy pickings: unset
UI/UX: unset

Looking at the two lines changed makes it pretty clear that backwards compatibility remains intact. The only thing it does is allow for the option to be omitted.

comment:5 by Amin Mirzaee, 12 years ago

Triage Stage: Design decision neededReady for checkin

comment:6 by Aymeric Augustin, 12 years ago

Triage Stage: Ready for checkinDesign decision needed

Please don't move a ticket out of DDN — that's a privilege of the core devs — and don't mark your own patches as RFC — we like to have two sets of eyes on a patch before it's marked as RFC.

You can learn more about our workflow in the triage guide. Thanks for your understanding!

comment:7 by Aymeric Augustin, 11 years ago

Needs documentation: set
Triage Stage: Design decision neededAccepted

My JavaScript-fu is weak, but I'll try to move this forward...

Apparently, JavaScript silently drop superfluous arguments, making this backwards-compatible. Julien, which backwards-incompatibilities did you have in mind?

It still requires documenting the change.

comment:8 by Baptiste Mispelon, 2 years ago

Resolution: invalid
Status: newclosed

My js knowledge is not super strong but I think what this ticket is asking already works.
In javascript, function parameters are always optional (and default to undefined).

The documentation already shows example where named is not required: https://docs.djangoproject.com/en/4.0/topics/i18n/translation/#interpolate

There are also tests using interpolate without named: https://github.com/django/django/blob/806efe912b846c1fde250c9321d8334b7517cd56/tests/view_tests/templates/jsi18n.html#L23

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