Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pages translatable #586

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions templates/_includes/translations.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{% macro entry_hreflang(entry) %}
{% if entry.translations %}
{% for translation in entry.translations %}
<link rel="alternate" hreflang="{{ translation.lang }}" href="{{ SITEURL }}/{{ translation.url }}">
{% endfor %}
{% endif %}
{% endmacro %}

{% macro translations_for(article) %}
{% if article.translations %}
<p id="list-of-translations">
Expand Down
5 changes: 5 additions & 0 deletions templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
{% block head_links %}
{{ super() }}
{% include '_includes/photos_header.html' %}

{% import 'translations.html' as translations with context %}
{% if translations.entry_hreflang(article) %}
{{ translations.entry_hreflang(article) }}
{% endif %}
{% endblock head_links %}

{% block content %}
Expand Down
10 changes: 10 additions & 0 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
{{ smo_metadata(page) }}
{% endblock meta_tags_in_head %}

{% block head_links %}
{{ super() }}
{% import 'translations.html' as translations with context %}
{% if translations.entry_hreflang(page) %}
{{ translations.entry_hreflang(page) }}
{% endif %}
{% endblock head_links %}

{% block content %}
<article>
<div class="row-fluid">
Expand All @@ -41,6 +49,8 @@ <h4>Contents</h4>
<div class="span8 offset2 article-content">
{% endif %}

{% import '_includes/translations.html' as translations with context %}
{{ translations.translations_for(page) }}
{{ page.content }}
{% from '_includes/comments.html' import comments_section with context %}
{{ comments_section(page) }}
Expand Down