Opened 13 months ago

Last modified 11 months ago

#22106 assigned Bug

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: Unreviewed
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 (2)

comment:1 Changed 12 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 11 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
Note: See TracTickets for help on using tickets.
Back to Top