From 6bb2175ed65456dda2f8ba584f206ba4bbd43dbc Mon Sep 17 00:00:00 2001 From: Moritz Sichert Date: Sun, 23 Feb 2014 15:10:31 +0100 Subject: Fixed #22106 -- Allowed using more than one instance of javascript_catalog per project. --- docs/releases/1.9.txt | 3 +++ docs/topics/i18n/translation.txt | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'docs') diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index bce55085ef..6ec8a3f455 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -143,6 +143,9 @@ Internationalization * The :func:`django.views.i18n.set_language` view now properly redirects to :ref:`translated URLs `, when available. +* The :func:`django.views.i18n.javascript_catalog` view now works correctly + if used multiple times with different configurations on the same page. + Management Commands ^^^^^^^^^^^^^^^^^^^ diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 0f7e76756b..ea295ae8ca 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -952,6 +952,31 @@ different apps and this changes often and you don't want to pull in one big catalog file. As a security measure, these values can only be either ``django.conf`` or any package from the :setting:`INSTALLED_APPS` setting. +You can also split the catalogs in multiple URLs and load them as you need in +your sites:: + + js_info_dict_app = { + 'packages': ('your.app.package',), + } + + js_info_dict_other_app = { + 'packages': ('your.other.app.package',), + } + + urlpatterns = [ + url(r'^jsi18n/app/$', javascript_catalog, js_info_dict_app), + url(r'^jsi18n/other_app/$', javascript_catalog, js_info_dict_other_app), + ] + +If you use more than one ``javascript_catalog`` on a site and some of them +define the same strings, the strings in the catalog that was loaded last take +precedence. + +.. versionchanged:: 1.9 + + Before Django 1.9, the catalogs completely overwrote each other and you + could only use one at a time. + The JavaScript translations found in the paths listed in the :setting:`LOCALE_PATHS` setting are also always included. To keep consistency with the translations lookup order algorithm used for Python and templates, the -- cgit v1.3