diff options
Diffstat (limited to 'sneakyidea/templates/translations.html')
-rw-r--r-- | sneakyidea/templates/translations.html | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sneakyidea/templates/translations.html b/sneakyidea/templates/translations.html index 0079883..5dacc95 100644 --- a/sneakyidea/templates/translations.html +++ b/sneakyidea/templates/translations.html @@ -1,6 +1,16 @@ -{% if article.translations %} -Translations: - {% for translation in article.translations %} - <a href="{{ SITEURL }}/{{ translation.url }}">{{ translation.lang }}</a> - {% endfor %} -{% endif %} +<!-- Takes a content (page, article,...) and translate it if possible--> +{% macro translate(content, sub_destination=None) -%} + {% if content.translations %} + Translations: + {% for translation in content.translations %} + {% if sub_destination %} + {% if sub_destination.endswith('/') %} + sub_destination = sub_destination[:-1] + {% endif %} + <a href="{{ SITEURL }}/{{ sub_destination }}/{{ translation.url }}">{{ translation.lang }}</a> + {% else %} + <a href="{{ SITEURL }}/{{ translation.url }}">{{ translation.lang }}</a> + {% endif %} + {% endfor %} + {% endif %} +{%- endmacro %} |