Added headings to i18n template tags and filters.
This commit is contained in:
parent
84522c0d16
commit
9ca0961b8a
|
@ -816,18 +816,33 @@ Other tags
|
|||
|
||||
These tags also require a ``{% load i18n %}``.
|
||||
|
||||
* ``{% get_available_languages as LANGUAGES %}`` returns a list of tuples in
|
||||
.. templatetag:: get_available_languages
|
||||
|
||||
``get_available_languages``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``{% get_available_languages as LANGUAGES %}`` returns a list of tuples in
|
||||
which the first element is the :term:`language code` and the second is the
|
||||
language name (translated into the currently active locale).
|
||||
|
||||
* ``{% get_current_language as LANGUAGE_CODE %}`` returns the current user's
|
||||
preferred language, as a string. Example: ``en-us``. (See
|
||||
:ref:`how-django-discovers-language-preference`.)
|
||||
.. templatetag:: get_current_language
|
||||
|
||||
* ``{% get_current_language_bidi as LANGUAGE_BIDI %}`` returns the current
|
||||
locale's direction. If True, it's a right-to-left language, e.g.: Hebrew,
|
||||
Arabic. If False it's a left-to-right language, e.g.: English, French, German
|
||||
etc.
|
||||
``get_current_languages``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``{% get_current_language as LANGUAGE_CODE %}`` returns the current user's
|
||||
preferred language as a string. Example: ``en-us``. See
|
||||
:ref:`how-django-discovers-language-preference`.
|
||||
|
||||
.. templatetag:: get_current_language_bidi
|
||||
|
||||
``get_current_language_bidi``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``{% get_current_language_bidi as LANGUAGE_BIDI %}`` returns the current
|
||||
locale's direction. If ``True``, it's a right-to-left language, e.g. Hebrew,
|
||||
Arabic. If ``False`` it's a left-to-right language, e.g. English, French,
|
||||
German, etc.
|
||||
|
||||
If you enable the ``django.template.context_processors.i18n`` context processor
|
||||
then each ``RequestContext`` will have access to ``LANGUAGES``,
|
||||
|
@ -837,6 +852,11 @@ then each ``RequestContext`` will have access to ``LANGUAGES``,
|
|||
|
||||
The ``i18n`` context processor is not enabled by default for new projects.
|
||||
|
||||
.. templatetag:: get_language_info
|
||||
|
||||
``get_language_info``
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can also retrieve information about any of the available languages using
|
||||
provided template tags and filters. To get information about a single language,
|
||||
use the ``{% get_language_info %}`` tag::
|
||||
|
@ -851,6 +871,11 @@ You can then access the information::
|
|||
Name in English: {{ lang.name }}<br />
|
||||
Bi-directional: {{ lang.bidi }}
|
||||
|
||||
.. templatetag:: get_language_info_list
|
||||
|
||||
``get_language_info_list``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can also use the ``{% get_language_info_list %}`` template tag to retrieve
|
||||
information for a list of languages (e.g. active languages as specified in
|
||||
:setting:`LANGUAGES`). See :ref:`the section about the set_language redirect
|
||||
|
@ -871,6 +896,13 @@ you can iterate over those languages in the template::
|
|||
{% get_language_info_list for available_languages as langs %}
|
||||
{% for lang in langs %} ... {% endfor %}
|
||||
|
||||
.. templatefilter:: language_name
|
||||
.. templatefilter:: language_name_local
|
||||
.. templatefilter:: language_bidi
|
||||
|
||||
Template filters
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
There are also simple filters available for convenience:
|
||||
|
||||
* ``{{ LANGUAGE_CODE|language_name }}`` ("German")
|
||||
|
|
Loading…
Reference in New Issue