Opened 14 years ago
Closed 3 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)
Change History (9)
by , 14 years ago
Attachment: | interpolate_mod.diff added |
---|
comment:1 by , 14 years ago
Component: | Translations → Internationalization |
---|
comment:2 by , 14 years ago
milestone: | 1.3 |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:4 by , 13 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 , 13 years ago
Triage Stage: | Design decision needed → Ready for checkin |
---|
comment:6 by , 13 years ago
Triage Stage: | Ready for checkin → Design 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 , 12 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Design decision needed → Accepted |
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 , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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
Making this change would likely break backwards compatibility. Needs more design discussion.