class JavaScriptCatalog [source]
A view that produces a JavaScript code library with functions that mimic the gettext interface, plus an array of translation strings.
Attributes
-
domain -
Translation domain containing strings to add in the view output. Defaults to
'djangojs'.
-
packages -
A list of
application namesamong installed applications. Those apps should contain alocaledirectory. All those catalogs plus all catalogs found inLOCALE_PATHS(which are always included) are merged into one catalog. Defaults toNone, which means that all available translations from allINSTALLED_APPSare provided in the JavaScript output.
Example with default values:
from django.views.i18n import JavaScriptCatalog
urlpatterns = [
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
]
Example with custom packages:
urlpatterns = [
url(r'^jsi18n/myapp/$',
JavaScriptCatalog.as_view(packages=['your.app.label']),
name='javascript-catalog'),
]
The precedence of translations is such that the packages appearing later in the packages argument have higher precedence than the ones appearing at the beginning. This is important in the case of clashing translations for the same literal.
If you use more than one JavaScriptCatalog view on a site and some of them define the same strings, the strings in the catalog that was loaded last take precedence.
Please login to continue.