Is it possible to loop through locales? For example:

{% locale in craft.locales %}
    {# get link for each locale available #}
    <a href="{{ locale.getUrl }}">{{ locale.title }}</a>
{% endfor %}

1 Answer 1


You can try to use the following code to loop through the locales:

{% set locales = craft.i18n.getSiteLocaleIds()%}

{% for locale in locales %}
    {% set localeEntry = craft.entries.id(entry.id).locale(locale).first %}
    <a href="{{ localeEntry.getUrl() }}">{{ localeEntry.title }}</a>
{% endfor %}

A full solution for a language switcher is described under How can I build a language switcher?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.