webseite/templates/macros/translator.j2
2019-12-02 01:05:55 +01:00

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 %}