Skip to content

Commit

Permalink
[1.9.x] Added some function links in translation docs
Browse files Browse the repository at this point in the history
Backport of 9a6fc96 from master.
  • Loading branch information
claudep committed Oct 7, 2015
1 parent fbe8930 commit c894f21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/ref/utils.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,12 @@ For a complete discussion on the usage of the following see the

``override`` is now usable as a function decorator.

.. function:: check_for_language(lang_code)

Checks whether there is a global language file for the given language
code (e.g. 'fr', 'pt_BR'). This is used to decide whether a user-provided
language is available.

.. function:: get_language()

Returns the currently selected language code. Returns ``None`` if
Expand Down
11 changes: 6 additions & 5 deletions docs/topics/i18n/translation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1888,14 +1888,15 @@ For example::
Calling this function with the value 'de' will give you ``"Willkommen"``,
regardless of :setting:`LANGUAGE_CODE` and language set by middleware.

Functions of particular interest are ``django.utils.translation.get_language()``
which returns the language used in the current thread,
``django.utils.translation.activate()`` which activates a translation catalog
for the current thread, and ``django.utils.translation.check_for_language()``
Functions of particular interest are
:func:`django.utils.translation.get_language()` which returns the language used
in the current thread, :func:`django.utils.translation.activate()` which
activates a translation catalog for the current thread, and
:func:`django.utils.translation.check_for_language()`
which checks if the given language is supported by Django.

To help write more concise code, there is also a context manager
``django.utils.translation.override()`` that stores the current language on
:func:`django.utils.translation.override()` that stores the current language on
enter and restores it on exit. With it, the above example becomes::

from django.utils import translation
Expand Down

0 comments on commit c894f21

Please sign in to comment.