Added some function links in translation docs
This commit is contained in:
parent
a76309f007
commit
9a6fc9606c
|
@ -1077,6 +1077,12 @@ For a complete discussion on the usage of the following see the
|
||||||
|
|
||||||
``override`` is also usable as a function decorator.
|
``override`` is also 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()
|
.. function:: get_language()
|
||||||
|
|
||||||
Returns the currently selected language code. Returns ``None`` if
|
Returns the currently selected language code. Returns ``None`` if
|
||||||
|
|
|
@ -1878,14 +1878,15 @@ For example::
|
||||||
Calling this function with the value 'de' will give you ``"Willkommen"``,
|
Calling this function with the value 'de' will give you ``"Willkommen"``,
|
||||||
regardless of :setting:`LANGUAGE_CODE` and language set by middleware.
|
regardless of :setting:`LANGUAGE_CODE` and language set by middleware.
|
||||||
|
|
||||||
Functions of particular interest are ``django.utils.translation.get_language()``
|
Functions of particular interest are
|
||||||
which returns the language used in the current thread,
|
:func:`django.utils.translation.get_language()` which returns the language used
|
||||||
``django.utils.translation.activate()`` which activates a translation catalog
|
in the current thread, :func:`django.utils.translation.activate()` which
|
||||||
for the current thread, and ``django.utils.translation.check_for_language()``
|
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.
|
which checks if the given language is supported by Django.
|
||||||
|
|
||||||
To help write more concise code, there is also a context manager
|
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::
|
enter and restores it on exit. With it, the above example becomes::
|
||||||
|
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
|
Loading…
Reference in New Issue