Opened 22 months ago

Closed 9 months ago

#22106 closed Bug (fixed)

catalogs of django.views.i18n.javascript_catalog overwrite each other

Reported by: moritzs Owned by: MoritzS
Component: Internationalization Version: master
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


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.


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 Changed 22 months ago by moritzs

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to moritzs
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 20 months ago by moritzs

  • Summary changed from Make django.views.i18n.javascript_catalog more flexible to catalogs of django.views.i18n.javascript_catalog overwrite each other
  • Type changed from Cleanup/optimization to Bug

comment:3 Changed 9 months ago by MoritzS

  • Owner changed from moritzs to MoritzS

comment:4 Changed 9 months ago by timgraham

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 9 months ago by timgraham

  • Patch needs improvement set

comment:6 Changed 9 months ago by MoritzS

  • Patch needs improvement unset
  • Triage Stage changed from Accepted to Ready for checkin

Thank you for your comments!
I corrected the errors and tests are now also passing in python2.7.

comment:7 Changed 9 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 6bb2175:

Fixed #22106 -- Allowed using more than one instance of javascript_catalog per project.

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