Refs #27656 -- Removed "This will" prefix from djanog/templatetags/i18n.py docstrings.

This commit is contained in:
Tim Graham 2018-03-21 08:07:42 -04:00
parent abe6c5defe
commit ba76c3c45b
1 changed files with 27 additions and 32 deletions

View File

@ -192,8 +192,7 @@ class LanguageNode(Node):
@register.tag("get_available_languages") @register.tag("get_available_languages")
def do_get_available_languages(parser, token): def do_get_available_languages(parser, token):
""" """
This will store a list of available languages Store a list of available languages in the context.
in the context.
Usage:: Usage::
@ -202,9 +201,7 @@ def do_get_available_languages(parser, token):
... ...
{% endfor %} {% endfor %}
This will just pull the LANGUAGES setting from This puts settings.LANGUAGES into the named variable.
your setting file (or the default settings) and
put it into the named variable.
""" """
# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments # token.split_contents() isn't useful here because this tag doesn't accept variable as arguments
args = token.contents.split() args = token.contents.split()
@ -216,8 +213,8 @@ def do_get_available_languages(parser, token):
@register.tag("get_language_info") @register.tag("get_language_info")
def do_get_language_info(parser, token): def do_get_language_info(parser, token):
""" """
This will store the language information dictionary for the given language Store the language information dictionary for the given language code in a
code in a context variable. context variable.
Usage:: Usage::
@ -237,10 +234,10 @@ def do_get_language_info(parser, token):
@register.tag("get_language_info_list") @register.tag("get_language_info_list")
def do_get_language_info_list(parser, token): def do_get_language_info_list(parser, token):
""" """
This will store a list of language information dictionaries for the given Store a list of language information dictionaries for the given language
language codes in a context variable. The language codes can be specified codes in a context variable. The language codes can be specified either as
either as a list of strings or a settings.LANGUAGES style list (or any a list of strings or a settings.LANGUAGES style list (or any sequence of
sequence of sequences whose first items are language codes). sequences whose first items are language codes).
Usage:: Usage::
@ -283,15 +280,14 @@ def language_bidi(lang_code):
@register.tag("get_current_language") @register.tag("get_current_language")
def do_get_current_language(parser, token): def do_get_current_language(parser, token):
""" """
This will store the current language in the context. Store the current language in the context.
Usage:: Usage::
{% get_current_language as language %} {% get_current_language as language %}
This will fetch the currently active language and This fetches the currently active language and puts its value into the
put it's value into the ``language`` context ``language`` context variable.
variable.
""" """
# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments # token.split_contents() isn't useful here because this tag doesn't accept variable as arguments
args = token.contents.split() args = token.contents.split()
@ -303,15 +299,15 @@ def do_get_current_language(parser, token):
@register.tag("get_current_language_bidi") @register.tag("get_current_language_bidi")
def do_get_current_language_bidi(parser, token): def do_get_current_language_bidi(parser, token):
""" """
This will store the current language layout in the context. Store the current language layout in the context.
Usage:: Usage::
{% get_current_language_bidi as bidi %} {% get_current_language_bidi as bidi %}
This will fetch the currently active language's layout and This fetches the currently active language's layout and puts its value into
put it's value into the ``bidi`` context variable. the ``bidi`` context variable. True indicates right-to-left layout,
True indicates right-to-left layout, otherwise left-to-right otherwise left-to-right.
""" """
# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments # token.split_contents() isn't useful here because this tag doesn't accept variable as arguments
args = token.contents.split() args = token.contents.split()
@ -323,33 +319,32 @@ def do_get_current_language_bidi(parser, token):
@register.tag("trans") @register.tag("trans")
def do_translate(parser, token): def do_translate(parser, token):
""" """
This will mark a string for translation and will Mark a string for translation and translate the string for the current
translate the string for the current language. language.
Usage:: Usage::
{% trans "this is a test" %} {% trans "this is a test" %}
This will mark the string for translation so it will This marks the string for translation so it will be pulled out by
be pulled out by mark-messages.py into the .po files makemessages into the .po files and runs the string through the translation
and will run the string through the translation engine. engine.
There is a second form:: There is a second form::
{% trans "this is a test" noop %} {% trans "this is a test" noop %}
This will only mark for translation, but will return This marks the string for translation, but returns the string unchanged.
the string unchanged. Use it when you need to store Use it when you need to store values into forms that should be translated
values into forms that should be translated later on. later on.
You can use variables instead of constant strings You can use variables instead of constant strings
to translate stuff you marked somewhere else:: to translate stuff you marked somewhere else::
{% trans variable %} {% trans variable %}
This will just try to translate the contents of This tries to translate the contents of the variable ``variable``. Make
the variable ``variable``. Make sure that the string sure that the string in there is something that is in the .po file.
in there is something that is in the .po file.
It is possible to store the translated string into a variable:: It is possible to store the translated string into a variable::
@ -417,7 +412,7 @@ def do_translate(parser, token):
@register.tag("blocktrans") @register.tag("blocktrans")
def do_block_translate(parser, token): def do_block_translate(parser, token):
""" """
This will translate a block of text with parameters. Translate a block of text with parameters.
Usage:: Usage::
@ -539,7 +534,7 @@ def do_block_translate(parser, token):
@register.tag @register.tag
def language(parser, token): def language(parser, token):
""" """
This will enable the given language just for this block. Enable the given language just for this block.
Usage:: Usage::