<p>You can try to use the following code to loop through the locales:</p>

<pre><code>{% set locales = craft.i18n.getSiteLocaleIds()%}

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

<p>A full solution for a language switcher is described under <a href="https://craftcms.stackexchange.com/questions/44/how-can-i-build-a-language-switcher">How can I build a language switcher?</a></p>

CC BY-SA 3.0
2015-08-01T06:57:24.630Z
I think it's a better idea to define the order manually with a custom array and loop through that. See code here: [How do I create a locale dropdown to switch between languages?](http://craftcms.stackexchange.com/q/877/125)
carlcs
CC BY-SA 3.0
2015-08-01T06:44:41.867Z
2015-08-01T06:44:41.867Z
2017-04-13T12:51:00.253Z
Tom Bauer
<p>Is it possible to loop through locales? For example:</p>

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

<localization>
Is it possible to loop through locales?
# Is it possible to loop through locales?

(Asked by: username_0 on 2015-08-01)

Is it possible to loop through locales? For example:
{% locale in craft.locales %}
    {# get link for each locale available #}
    {{ locale.title }}
{% endfor %}

**Tags:** localization

---

## 1 answers

### Answer by username_1 on 2015-08-01. Score: 4 | Accepted answer

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 %}
    {{ localeEntry.title }}
{% endfor %}

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

> **Comments:**
> **username_2**: I think it's a better idea to define the order manually with a custom array and loop through that. See code here: [How do I create a locale dropdown to switch between languages?](http://craftcms.stackexchange.com/q/877/125)  

---

