14 lines
465 B
Django/Jinja
14 lines
465 B
Django/Jinja
{#- text -> key in databag,
|
|
bag_name -> name of databag,
|
|
language -> language to translate to,
|
|
fallback -> fallback language when translation is not available
|
|
#}
|
|
{%- macro translator(text, bag_name, language, fallback='de') %}
|
|
{%- if bag(bag_name, language, text) -%}
|
|
{{ bag(bag_name, language, text) }}
|
|
{%- elif bag(bag_name, fallback, text) -%}
|
|
{{ bag(bag_name, fallback, text) }}
|
|
{%- else -%}
|
|
{{ text }}
|
|
{%- endif %}
|
|
{%- endmacro %}
|