aboutsummaryrefslogtreecommitdiffstats
path: root/sneakyidea
diff options
context:
space:
mode:
Diffstat (limited to 'sneakyidea')
-rw-r--r--sneakyidea/templates/article_infos.html3
-rw-r--r--sneakyidea/templates/page.html3
-rw-r--r--sneakyidea/templates/translations.html22
3 files changed, 21 insertions, 7 deletions
diff --git a/sneakyidea/templates/article_infos.html b/sneakyidea/templates/article_infos.html
index 3a028a1..1a47e70 100644
--- a/sneakyidea/templates/article_infos.html
+++ b/sneakyidea/templates/article_infos.html
@@ -1,3 +1,4 @@
+{% import 'translations.html' as translations with context %}
<footer class="post-info">
<abbr class="published" title="{{ article.date.isoformat() }}">
{{ article.locale_date }}
@@ -10,5 +11,5 @@
{% endif %}
<p>In <a href="{{ SITEURL }}/category/{{ article.category }}.html">{{ article.category }}</a>. {% if PDF_PROCESSOR %}<a href="{{ SITEURL }}/pdf/{{ article.slug }}.pdf">get the pdf</a>{% endif %}</p>
{% include 'taglist.html' %}
-{% include 'translations.html' %}
+{{ translations.translate(article) }}
</footer><!-- /.post-info -->
diff --git a/sneakyidea/templates/page.html b/sneakyidea/templates/page.html
index 9635fb8..e99070a 100644
--- a/sneakyidea/templates/page.html
+++ b/sneakyidea/templates/page.html
@@ -1,8 +1,11 @@
+{% import 'translations.html' as translations with context %}
{% extends "base.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block content %}
<section id="content" class="body">
<h1 class="entry-title">{{ page.title }}</h1>
+ {{ translations.translate(page, 'pages') }}
+ <br /><br />
{% if PDF_PROCESSOR %}<a href="{{ SITEURL }}/pdf/{{ page.slug }}.pdf">get
the pdf</a>{% endif %}
{{ page.content }}
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 %}