diff options
author | Arnaud BOS <arnaud.tlse@gmail.com> | 2011-05-08 13:40:44 +0100 |
---|---|---|
committer | Arnaud BOS <arnaud.tlse@gmail.com> | 2011-05-08 13:40:44 +0100 |
commit | a2d78d158960e72b760bd965797115f1fbb38778 (patch) | |
tree | 3da5ca2dd88ec9f9daa9a4383759fc2e3f50e21b /sneakyidea | |
parent | 69c1767f4468f25a50b9c44386adfa16104b670c (diff) | |
download | pelican-themes-a2d78d158960e72b760bd965797115f1fbb38778.zip pelican-themes-a2d78d158960e72b760bd965797115f1fbb38778.tar.gz pelican-themes-a2d78d158960e72b760bd965797115f1fbb38778.tar.bz2 |
[SNEAKYIDEA]Add translation support to pages.
Diffstat (limited to 'sneakyidea')
-rw-r--r-- | sneakyidea/templates/article_infos.html | 3 | ||||
-rw-r--r-- | sneakyidea/templates/page.html | 3 | ||||
-rw-r--r-- | sneakyidea/templates/translations.html | 22 |
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 %} |