I'm currently building a site with two languages, and I need a language switcher so wherever you enter the website you can switch the language easily.
I've come this far:
{% for locale in craft.i18n.getSiteLocales() %}
<li {{ locale == craft.i18n.getCurrentLocale() ? 'class="active"' }}>
<a href="/{{ locale }}/{{ entry.slug }}">
{% if loop.first %}DE{% else %}FR{% endif %}
</a>
</li>
{% endfor %}
The problem here is that {{ entry.slug }}
only returns the slug for the current language and doesn't loop trough the languages.
When I'm on french it returns /bonjour
twice and on german it returns /hallo
twice. Why is that?