From a2d78d158960e72b760bd965797115f1fbb38778 Mon Sep 17 00:00:00 2001 From: Arnaud BOS Date: Sun, 8 May 2011 13:40:44 +0100 Subject: [PATCH] [SNEAKYIDEA]Add translation support to pages. --- sneakyidea/templates/article_infos.html | 3 ++- sneakyidea/templates/page.html | 3 +++ 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 3a028a1c2..1a47e70fc 100644 --- a/sneakyidea/templates/article_infos.html +++ b/sneakyidea/templates/article_infos.html @@ -1,3 +1,4 @@ +{% import 'translations.html' as translations with context %} diff --git a/sneakyidea/templates/page.html b/sneakyidea/templates/page.html index 9635fb8d6..e99070a9e 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 %}

{{ page.title }}

+ {{ translations.translate(page, 'pages') }} +

{% if PDF_PROCESSOR %}get the pdf{% endif %} {{ page.content }} diff --git a/sneakyidea/templates/translations.html b/sneakyidea/templates/translations.html index 0079883ea..5dacc951b 100644 --- a/sneakyidea/templates/translations.html +++ b/sneakyidea/templates/translations.html @@ -1,6 +1,16 @@ -{% if article.translations %} -Translations: - {% for translation in article.translations %} - {{ translation.lang }} - {% endfor %} -{% endif %} + +{% 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 %} + {{ translation.lang }} + {% else %} + {{ translation.lang }} + {% endif %} + {% endfor %} + {% endif %} +{%- endmacro %}