[SNEAKYIDEA]Add translation support to pages.

This commit is contained in:
Arnaud BOS
2011-05-08 13:40:44 +01:00
parent 69c1767f44
commit a2d78d1589
3 changed files with 21 additions and 7 deletions

View File

@@ -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 -->

View File

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

View File

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