Skip to content

Instantly share code, notes, and snippets.

@umkasanki
Created April 15, 2018 13:00
Show Gist options
  • Save umkasanki/bd77a9d8ff19c0e2ba5e389ceab2c31b to your computer and use it in GitHub Desktop.
Save umkasanki/bd77a9d8ff19c0e2ba5e389ceab2c31b to your computer and use it in GitHub Desktop.
Simple multilanguage nav
{% set navlist = nav.navlist %}
{% for item in navlist %}
<a href="{{ item.url }}">{{ item.title | t }}</a>
{% if loop.last %}
{% for locale in craft.i18n.getSiteLocales() %}
{% set localeData = craft.i18n.getLocaleData(locale.id) %}
{% if entry is not null %}
{% if craft.locale != locale %}
{% set localisedEntry = craft.entries.id(entry.id).locale(locale.id).first() %}
<a href="{{ localisedEntry.url }}">{{ locale | upper }}</a>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment