<ul id="lang-links">
	{% assign pathComponents = page.path | split: '/' %}
	{% for pathComponent in pathComponents limit: 1 %}
		{% if pathComponent.size == 2 %}
			{% assign basename = page.path | remove_first: pathComponent | remove_first: '/' %}
		{% else %}
			{% assign basename = page.path %}
		{% endif %}
	{% endfor %}
	{% for lang in site.languages %}
		{% if lang == 'en' %}
			{% assign langPath = basename %}
		{% else %}
			{% assign langPath = basename | prepend: '/' | prepend: lang %}
		{% endif %}
		{% assign langPages = site.pages | where: 'path', langPath %}
		{% for langPage in langPages %}
			<li class="lang-link{%if page.path == langPage.path%} current{%endif%}"><a href="{{ langPage.url | remove: 'index.html'}}">{{lang}}</a></li>
		{% endfor %}
	{% endfor %}
</ul>
