Opened 11 years ago
Closed 10 years ago
#22106 closed Bug (fixed)
catalogs of django.views.i18n.javascript_catalog overwrite each other
Reported by: | Moritz Sichert | Owned by: | Moritz Sichert |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | jsi18n javascript catalog |
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 |
Description
Right now you can only use one instance of javascript_catalog
, because they will override each other if you add more to one site.
This problem can easily be solved by making packages
in kwargs
for javascript_catalog
include all packages needed instead of having a multiple views for different packages. That however makes the internationalization of javascript code that does not directly lie in the main application somewhat inflexible.
Example
appA
: app that contains the widget FunkyJSWidget
that relies on some javascript and needs jsi18n.
appMain
: your main app that contains all the views for your website. Your website also contains some javascript code that also uses jsi18n. It uses appA.FunkyJSWidget
on some forms as well.
INSTALLED_APPS
now is ('appA', 'appMain')
.
The problem now occurs on all your pages that use appA.FunkyJSWidget
. Because the widget includes its javascript_catalog (per Media-class for example) as well as your appMain
, one will override the other. You could obviously add appA
to appMain.views.jsi18n
's packages
argument but this shouldn't be necessary.
Possible Solution
Modify django.views.i18n.js_catalog_template
to detect if a catalog already exists. If it does, update it instead of overriding it. A minor issue is that the template omits some functions if they are not needed. That should be checked for all included javascript_catalogs, too.
Change History (7)
comment:1 by , 11 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 11 years ago
Summary: | Make django.views.i18n.javascript_catalog more flexible → catalogs of django.views.i18n.javascript_catalog overwrite each other |
---|---|
Type: | Cleanup/optimization → Bug |
comment:3 by , 10 years ago
Owner: | changed from | to
---|
comment:4 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 10 years ago
Patch needs improvement: | set |
---|
comment:6 by , 10 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Thank you for your comments!
I corrected the errors and tests are now also passing in python2.7.
pull request: https://github.com/django/django/pull/2362