Skip to content

Commit

Permalink
Support article translation
Browse files Browse the repository at this point in the history
  • Loading branch information
maparent authored and alexandrevicenzi committed Apr 22, 2017
1 parent a6f12ec commit 1802e84
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions static/stylesheet/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ main {
color: @header-text-color;
font-size: 0.86em;
}

.translations {
float: right;

.lang-current {
color: @white;
background-color: @grey;
}
}
}

code, kbd, samp, pre {
Expand Down
2 changes: 1 addition & 1 deletion static/stylesheet/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
{% block content %}
<article class="single">
<header>
{% import 'partial/translations.html' as translations with context %}
{{ translations.translations_for(article) }}
<h1 id="{{ article.slug }}">{{ article.title }}</h1>
<p>
{{ _('Posted on %(when)s in %(category)s',
Expand Down
2 changes: 2 additions & 0 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{% block content %}
<article class="single">
<header>
{% import 'partial/translations.html' as translations with context %}
{{ translations.translations_for(page) }}
<h1 id="{{ page.slug }}">{{ page.title }}</h1>
</header>
<div>
Expand Down
10 changes: 10 additions & 0 deletions templates/partial/translations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% macro translations_for(article) %}
{% if article.translations %}
<div class="translations">
<span class="lang lang-current">{{article.lang}}</span>
{% for translation in article.translations %}
<a class="lang" href="{{ SITEURL }}/{{ translation.url }}">{{ translation.lang }}</a>
{% endfor %}
</div>
{% endif %}
{% endmacro %}

0 comments on commit 1802e84

Please sign in to comment.