[Django] #22106: Make django.views.i18n.javascript_catalog more flexible

7 views
Skip to first unread message

Django

unread,
Feb 20, 2014, 10:32:24 AM2/20/14
to django-...@googlegroups.com
#22106: Make django.views.i18n.javascript_catalog more flexible
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: | Keywords: jsi18n javascript
Internationalization | catalog
Severity: Normal | Has patch: 0
Triage Stage: Unreviewed | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/22106>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 23, 2014, 10:12:38 AM2/23/14
to django-...@googlegroups.com
#22106: Make django.views.i18n.javascript_catalog more flexible
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: moritzs
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: | Resolution:
Internationalization | Triage Stage:
Severity: Normal | Unreviewed
Keywords: jsi18n javascript | Needs documentation: 0
catalog | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by moritzs):

* status: new => assigned
* needs_better_patch: => 0
* needs_tests: => 0
* owner: nobody => moritzs
* needs_docs: => 0
* has_patch: 0 => 1


Comment:

pull request: https://github.com/django/django/pull/2362

--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:1>

Django

unread,
Apr 4, 2014, 9:38:03 AM4/4/14
to django-...@googlegroups.com
#22106: catalogs of django.views.i18n.javascript_catalog overwrite each other

-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: moritzs
Type: Bug | Status: assigned
Component: | Version: master
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: jsi18n javascript | Unreviewed
catalog | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by moritzs):

* type: Cleanup/optimization => Bug


--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:2>

Django

unread,
Mar 14, 2015, 10:51:09 AM3/14/15
to django-...@googlegroups.com
#22106: catalogs of django.views.i18n.javascript_catalog overwrite each other
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: MoritzS

Type: Bug | Status: assigned
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: jsi18n javascript | Triage Stage:
catalog | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MoritzS):

* owner: moritzs => MoritzS


--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:3>

Django

unread,
Mar 17, 2015, 6:52:14 PM3/17/15
to django-...@googlegroups.com
#22106: catalogs of django.views.i18n.javascript_catalog overwrite each other
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: MoritzS
Type: Bug | Status: assigned
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: jsi18n javascript | Triage Stage: Accepted
catalog |

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:4>

Django

unread,
Mar 20, 2015, 1:02:07 PM3/20/15
to django-...@googlegroups.com
#22106: catalogs of django.views.i18n.javascript_catalog overwrite each other
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: MoritzS
Type: Bug | Status: assigned
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: jsi18n javascript | Triage Stage: Accepted
catalog |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:5>

Django

unread,
Mar 20, 2015, 1:38:28 PM3/20/15
to django-...@googlegroups.com
#22106: catalogs of django.views.i18n.javascript_catalog overwrite each other
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: MoritzS
Type: Bug | Status: assigned
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: jsi18n javascript | Triage Stage: Ready for
catalog | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MoritzS):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:6>

Django

unread,
Mar 20, 2015, 5:28:52 PM3/20/15
to django-...@googlegroups.com
#22106: catalogs of django.views.i18n.javascript_catalog overwrite each other
-------------------------------------+-------------------------------------
Reporter: moritzs | Owner: MoritzS
Type: Bug | Status: closed
Component: | Version: master
Internationalization |
Severity: Normal | Resolution: fixed

Keywords: jsi18n javascript | Triage Stage: Ready for
catalog | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"6bb2175ed65456dda2f8ba584f206ba4bbd43dbc" 6bb2175]:
{{{
#!CommitTicketReference repository=""
revision="6bb2175ed65456dda2f8ba584f206ba4bbd43dbc"
Fixed #22106 -- Allowed using more than one instance of javascript_catalog
per project.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22106#comment:7>

Reply all
Reply to author
Forward
0 new messages