Ticket #13417: 13417-r13135.diff

File 13417-r13135.diff, 1.8 KB (added by Ramiro Morales, 15 years ago)

stephaher's patch expanded a bit. Applies to the 1.1.X branch too w/o need to port

  • docs/topics/i18n/internationalization.txt

    diff --git a/docs/topics/i18n/internationalization.txt b/docs/topics/i18n/internationalization.txt
    a b  
    449449The ``javascript_catalog`` view
    450450-------------------------------
    451451
    452 The main solution to these problems is the ``javascript_catalog`` view, which
    453 sends out a JavaScript code library with functions that mimic the ``gettext``
    454 interface, plus an array of translation strings. Those translation strings are
    455 taken from the application, project or Django core, according to what you
    456 specify in either the info_dict or the URL.
     452.. module:: django.views.i18n
     453
     454.. function:: def javascript_catalog(request, domain='djangojs', packages=None)
     455
     456The main solution to these problems is the ``django.views.i18n.javascript_catalog``
     457view, which sends out a JavaScript code library with functions that mimic the
     458``gettext`` interface, plus an array of translation strings. Those translation
     459strings are taken from the application, project or Django core, according to what
     460you specify in either the info_dict or the URL.
    457461
    458462You hook it up like this::
    459463
     
    471475those catalogs are merged into one catalog. This is useful if you have
    472476JavaScript that uses strings from different applications.
    473477
     478By default, the view uses the ``djangojs`` gettext domain which can be
     479changed by the ``domain`` argument.
     480
    474481You can make the view dynamic by putting the packages into the URL pattern::
    475482
    476483    urlpatterns = patterns('',
     
    541548The ``set_language`` redirect view
    542549==================================
    543550
     551.. function:: def set_language(request)
     552
    544553As a convenience, Django comes with a view, ``django.views.i18n.set_language``,
    545554that sets a user's language preference and redirects back to the previous page.
    546555
Back to Top