Undocumented
Variable | register |
Undocumented |
Class | BlockTranslateNode |
Undocumented |
Class | GetAvailableLanguagesNode |
Undocumented |
Class | GetCurrentLanguageBidiNode |
Undocumented |
Class | GetCurrentLanguageNode |
Undocumented |
Class | GetLanguageInfoListNode |
Undocumented |
Class | GetLanguageInfoNode |
Undocumented |
Class | LanguageNode |
Undocumented |
Class | TranslateNode |
Undocumented |
Function | do_block_translate |
Translate a block of text with parameters. |
Function | do_get_available_languages |
Store a list of available languages in the context. |
Function | do_get_current_language |
Store the current language in the context. |
Function | do_get_current_language_bidi |
Store the current language layout in the context. |
Function | do_get_language_info |
Store the language information dictionary for the given language code in a context variable. |
Function | do_get_language_info_list |
No summary |
Function | do_translate |
Mark a string for translation and translate the string for the current language. |
Function | language |
Enable the given language just for this block. |
Function | language_bidi |
Undocumented |
Function | language_name |
Undocumented |
Function | language_name_local |
Undocumented |
Function | language_name_translated |
Undocumented |
Translate a block of text with parameters.
Usage:
{% blocktranslate with bar=foo|filter boo=baz|filter %} This is {{ bar }} and {{ boo }}. {% endblocktranslate %}
Additionally, this supports pluralization:
{% blocktranslate count count=var|length %} There is {{ count }} object. {% plural %} There are {{ count }} objects. {% endblocktranslate %}
This is much like ngettext, only in template syntax.
The "var as value" legacy format is still supported:
{% blocktranslate with foo|filter as bar and baz|filter as boo %} {% blocktranslate count var|length as count %}
The translated string can be stored in a variable using asvar
:
{% blocktranslate with bar=foo|filter boo=baz|filter asvar var %} This is {{ bar }} and {{ boo }}. {% endblocktranslate %} {{ var }}
Contextual translations are supported:
{% blocktranslate with bar=foo|filter context "greeting" %} This is {{ bar }}. {% endblocktranslate %}
This is equivalent to calling pgettext/npgettext instead of (u)gettext/(u)ngettext.
Store a list of available languages in the context.
Usage:
{% get_available_languages as languages %} {% for language in languages %} ... {% endfor %}
This puts settings.LANGUAGES into the named variable.
Store the current language in the context.
Usage:
{% get_current_language as language %}
This fetches the currently active language and puts its value into the language context variable.
Store the current language layout in the context.
Usage:
{% get_current_language_bidi as bidi %}
This fetches the currently active language's layout and puts its value into the bidi context variable. True indicates right-to-left layout, otherwise left-to-right.
Store the language information dictionary for the given language code in a context variable.
Usage:
{% get_language_info for LANGUAGE_CODE as l %} {{ l.code }} {{ l.name }} {{ l.name_translated }} {{ l.name_local }} {{ l.bidi|yesno:"bi-directional,uni-directional" }}
Store a list of language information dictionaries for the given language codes in a context variable. The language codes can be specified either as a list of strings or a settings.LANGUAGES style list (or any sequence of sequences whose first items are language codes).
Usage:
{% get_language_info_list for LANGUAGES as langs %} {% for l in langs %} {{ l.code }} {{ l.name }} {{ l.name_translated }} {{ l.name_local }} {{ l.bidi|yesno:"bi-directional,uni-directional" }} {% endfor %}
Mark a string for translation and translate the string for the current language.
Usage:
{% translate "this is a test" %}
This marks the string for translation so it will be pulled out by makemessages into the .po files and runs the string through the translation engine.
There is a second form:
{% translate "this is a test" noop %}
This marks the string for translation, but returns the string unchanged. Use it when you need to store values into forms that should be translated later on.
You can use variables instead of constant strings to translate stuff you marked somewhere else:
{% translate variable %}
This tries to translate the contents of the variable variable. Make sure that the string in there is something that is in the .po file.
It is possible to store the translated string into a variable:
{% translate "this is a test" as var %} {{ var }}
Contextual translations are also supported:
{% translate "this is a test" context "greeting" %}
This is equivalent to calling pgettext instead of (u)gettext.