Skip to content

Commit c8fc271

Browse files
committed
(squash) fix linking to translations of current article
1 parent 9090f12 commit c8fc271

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

templates/index.html

+13-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,21 @@
4242
<nav itemscope itemtype="http://schema.org/SiteNavigationElement">
4343
{% if config.languages %}
4444
<div style="float: right">
45+
<!-- does not show the current language -->
4546
{% for key, value in config.languages %}
47+
{% set_global lang_url = value.translations.url | safe | replace(from="$BASE_URL", to=config.base_url) | replace(from="$LANG_BASE_URL", to=lang_base_url) %}
48+
<!-- check to see if the language has a translation of the current article -->
49+
{% if page %}
50+
{%for ea_translation in page.translations%}
51+
{%if ea_translation.lang == key%}
52+
{% set_global lang_url = ea_translation.permalink %}
53+
{%endif%}
54+
{% endfor %}
55+
{% elif taxonomy.slug %}
56+
{% set_global lang_url = value.translations.url ~ `/` ~ taxonomy.slug | safe | replace(from="$BASE_URL", to=config.base_url) | replace(from="$LANG_BASE_URL", to=lang_base_url) %}
57+
{% endif %}
4658
<a itemprop="url"
47-
class="navbar {% if value.translations.url | replace(from="$BASE_URL", to=config.base_url) | replace(from="$LANG_BASE_URL", to=lang_base_url) == current_url %}active{% endif %}"
48-
href="{{ value.translations.url | safe | replace(from="$BASE_URL", to=config.base_url) | replace(from="$LANG_BASE_URL", to=lang_base_url) }}">
59+
href="{{lang_url}}">
4960
<span itemprop="name">{% if value.translations.trans_key %}{{ trans(key=value.translations.trans_key, lang=lang) }}{% else %}{{ value.translations.name }}{% endif %}</span></a>
5061
{% endfor %}
5162
</div>

0 commit comments

Comments
 (0)