Django Integration

Django SDK offers a variety of template tags and filters that can be used in the Templates and Models. The following sections will provide a detailed description for every template tag and its options.

If label uses data or decoration tokens, the token values will be provided using this parameter.

description

string

false

Description of the label that acts as a hint to the translator as well as contextualizes the key to be unique for the description.

options

dict

false

Additional attributes.

Options:

nowrap - if set to true, content will not be decorated

activate

Activates Tml SDK for a given language for the current thread.

activate(language)

The main reason for this helper function is to use Tml outside views and templates. Remember to switch back to original language, as activating a language is done on per-thread basis and such change will affect code running in the same thread:

Properties:

with -

count -

context -

as -

trimmed -

nowrap -

blocktrans

This tag is used for backward compatibility with Django translations. So if you started using TML at the middle stage of your development, then you probably have a lot of Django-based translations. In order to start using TML without friction, SDK monkeypatches blocktrans (as well as other Django translation functionality) template tag. On usage details you can refer to Django documentation.

trs

This tag is a helper for translating labels without tokens.

{% trs user.name %}
{% trs "Hello world" %}

Properties:

context -

as -

nowrap -

tmlopts

If you would select some TML options like target_locale or source you can use this template tag.