Skip to content

Commit

Permalink
[SNEAKYIDEA]Add translation support to pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbos committed May 8, 2011
1 parent 69c1767 commit a2d78d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion sneakyidea/templates/article_infos.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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 -->
3 changes: 3 additions & 0 deletions sneakyidea/templates/page.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down
22 changes: 16 additions & 6 deletions sneakyidea/templates/translations.html
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit a2d78d1

Please sign in to comment.