added global variables for translated strings

This commit is contained in:
mb@mb 2018-06-13 18:46:31 +02:00
parent 92f732ce59
commit ebd461741f
2 changed files with 68 additions and 33 deletions

View File

@ -20,6 +20,27 @@
{% endfor %} {% endfor %}
</header> </header>
{% set glob={} %}
{% if article.translations %}
{% for translation in article.translations %}
{% if translation.lang == 'nl' %}
{% set _ = glob.update({'published_at': 'Published at '}) %}
{% set _ = glob.update({'translate_article': 'Lees dit artikel in het Nederlands'}) %}
{% set _ = glob.update({'related_to': ' relating to '}) %}
{% set _ = glob.update({'translation_url': translation.url}) %}
{% set _ = glob.update({'written_by': 'Written by '}) %}
{% endif %}
{% if translation.lang == 'en' %}
{% set _ = glob.update({'published_at': 'Gepubliceerd op '}) %}
{% set _ = glob.update({'translate_article': 'Read this article in English'}) %}
{% set _ = glob.update({'related_to': ' gerelateerd aan '}) %}
{% set _ = glob.update({'translation_url': translation.url}) %}
{% set _ = glob.update({'written_by': 'Geschreven door '}) %}
{% endif %}
{% endfor %}
{% endif %}
<section id="content" class="body h-entry"> <section id="content" class="body h-entry">
<div class="entry-title p-name"> <div class="entry-title p-name">
{{ article.title }} {{ article.title }}
@ -38,40 +59,40 @@
</div> </div>
<div class="event-details"> <div class="event-details">
{% if article.event_start %} {% if article.event_start %}
<div>{{ article.event_start }}</div> <div class="article-event-start">{{ article.event_start }}</div>
{% else %}
<div>Published: {{ article.date | strftime('%d %B %Y') }}</div>
{% endif %} {% endif %}
<div>{{ glob.published_at }} {{ article.date | strftime('%d %B %Y') }}</div>
</div> </div>
<div class="post-info"> <div class="post-info">
<a style="visibility:hidden;" rel="author" class="p-author h-card">{{article.author}}</a> <div class="article-authors">
<time class="dt-published" datetime="{{article.date}}"></time> {% if article.author %}
<a class="u-url" href="{{article.url}}"></a> {{ glob.written_by }}
{{ article.author }}
{% endif %}
</div>
<a style="visibility:hidden;" rel="author" class="p-author h-card">{{ article.author }}</a>
<time class="dt-published" datetime="{{ article.date }}"></time>
<a class="u-url" href="{{ article.url }}"></a>
{% if article.category %} {% if article.category %}
<span class="categories"> <span class="categories">
<span itemprop="articleSection"> <span itemprop="articleSection">
<a href="{{ article.category.url }}" rel="category">{{ article.category }}</a> <a href="/category{{ article.category.url }}" rel="category">{{ article.category }}</a>
</span> </span>
</span> </span>
{% endif %} {% endif %}
{% if article.translations %}
<span class="article-translation">
{% for translation in article.translations %}
{% if translation.lang == 'nl' %}<a href="{{ translation.url }}">Lees dit artikel in het Nederlands</a>
{% endif %}
{% if translation.lang == 'en' %}<a href="{{ translation.url }}">Read this article in English</a>
{% endif %}
{% endfor %}
</span>
{% endif %}
{% if article.tags %} {% if article.tags %}
<span class="tags"> <span class="tags">
relating to {% for tag in article.tags %} {{ glob.related_to }}
<span itemprop="keywords"> {% for tag in article.tags %}
<a href="/{{ tag.url }}" rel="tag">{{ tag }}</a> <span itemprop="keywords">
</span> {% endfor %} <a href="/{{ tag.url }}" rel="tag">{{ tag }}</a>
</span>
{% endfor %}
</span> </span>
{% endif %} {% endif %}
<div class="article-translation">
<a href="{{ glob.translation_url }}">{{ glob.translate_article }}</a>
</div>
</div> </div>
</div> </div>
<div class="entry-content-container"> <div class="entry-content-container">

View File

@ -10,13 +10,30 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</header> </header>
{% set glob={} %}
{% if DEFAULT_LANG == 'nl' %}
{% set _ = glob.update({'published_at': 'Gepubliceerd op '}) %}
{% set _ = glob.update({'related_to': ' gerelateerd aan '}) %}
{% set _ = glob.update({'written_by': 'Geschreven door '}) %}
{% set _ = glob.update({'read_more': 'lees meer '}) %}
{% endif %}
{% if DEFAULT_LANG == 'en' %}
{% set _ = glob.update({'published_at': 'Published at '}) %}
{% set _ = glob.update({'related_to': ' relating to '}) %}
{% set _ = glob.update({'written_by': 'Written by '}) %}
{% set _ = glob.update({'read_more': 'read more'}) %}
{% endif %}
{% block content_title %} {% block content_title %}
{% endblock %} {% endblock %}
{% if articles_page.has_other_pages() %} {% if articles_page.has_other_pages() %}
{% include 'pagination.html' %} {% include 'pagination.html' %}
{% endif %} {% endif %}
<div id="post-list">
<div id="post-list">
{% for article in articles_page.object_list %} {% for article in articles_page.object_list %}
{% set thumb_size = '/thumb' %} {% set thumb_size = '/thumb' %}
{% if article.category %} {% if article.category %}
@ -31,27 +48,23 @@
{% endif %} {% endif %}
{% if article.category == 'article' %} {% if article.category == 'article' %}
{% set thumb_size = '/thumb2x' %} {% set thumb_size = '/thumb2x' %}
{% endif %}
{% if article.category == 'documentation' %}
{% set thumb_size = '/thumb2x' %}
{% endif %} {% endif %}
{% endif %} {% endif %}
<article class="hentry {{article.category}}{{event_status}}"> <article class="hentry {{article.category}}{{event_status}}">
{% endif %} {% endif %}
<div class="article-info"> <div class="article-info">
<span class="entry-title"><a href="{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></span> <span class="entry-title"><a href="/{% if article.lang == 'en' %}en/{% endif %}{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></span>
{% if article.event_start %} {% if article.event_start %}
<div class="event-details"> <div class="event-details">
{{ article.event_start | strftime('%d %B %Y') }} {{ article.event_start | strftime('%d %B %Y') }}
<!-- {% set event_status = '' %} -->
</div> </div>
{% else %} {% else %}
<div class="event-details"></div> <div class="event-details"></div>
{% endif %} {% endif %}
<div class="featured-image {{event_status}}"> <div class="featured-image {{event_status}}">
{% if article.featured_image %} {% if article.featured_image %}
<a href="{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}"> <a href="/{% if article.lang == 'en' %}en/{% endif %}{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">
{% if article.featured_image.endswith('.gif') %} {% if article.featured_image.endswith('.gif') %}
{% set thumb_size =''%} {% set thumb_size =''%}
{% endif %} {% endif %}
@ -63,11 +76,11 @@
</div> </div>
<div class="summary {{ article.category }}">{{ article.summary }} <div class="summary {{ article.category }}">{{ article.summary }}
<span> <span class="read_more">
{% if DEFAULT_LANG == 'en' %} {% if DEFAULT_LANG == 'en' %}
<a href="/en/{{ article.url }}">read more</a> <a href="/en/{{ article.url }}">{{ glob.read_more }}</a>
{% elif DEFAULT_LANG == 'nl' %} {% elif DEFAULT_LANG == 'nl' %}
<a href="/{{ article.url }}">lees meer</a> <a href="/{{ article.url }}">{{ glob.read_more }}</a>
{% endif %} {% endif %}
</span> </span>
</div> </div>
@ -76,13 +89,14 @@
{% if article.category %} {% if article.category %}
<span class="categories"> <span class="categories">
<span itemprop="articleSection"> <span itemprop="articleSection">
<a href="/{{ article.category.url }}" rel="category">{{ article.category }}</a> <a href="/category{{ article.category.url }}" rel="category">{{ article.category }}</a>
</span> </span>
</span> </span>
{% endif %} {% endif %}
{% if article.tags %} {% if article.tags %}
<span class="tags"> <span class="tags">
relating to {% for tag in article.tags %} {{ glob.related_to }}
{% for tag in article.tags %}
<span itemprop="keywords"> <span itemprop="keywords">
<a href="/{{ tag.url }}" rel="tag">{{ tag }}</a> <a href="/{{ tag.url }}" rel="tag">{{ tag }}</a>
</span> {% endfor %} </span> {% endfor %}