[SNEAKYIDEA]Add translation support to pages.
This commit is contained in:
@@ -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 -->
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
Reference in New Issue
Block a user