I’m trying to create a dropdown menu to switch between language’s on my site. I am currently doing this with this snippet found on the google plus community:
{% block locale__switch %}
{# Loop through all of the site locales, except the current one #}
{% set otherLocales = craft.i18n.getSiteLocaleIds()|without(craft.locale) %}
{% for locale in otherLocales %}
{# Find the current entry in the other locale #}
{% set localeEntry = craft.entries.id(entry.id).locale(locale).first %}
{# Make sure that it's actually localized to this locale #}
{% if localeEntry.locale == locale %}
{# Output a link to it #}
<a href="{{ localeEntry.getUrl() }}" style="text-transform:uppercase;">{{ locale }}</a>
{% else %}
{# Output a link to the hompage #}
<a href="{{ craft.config.siteUrl[locale] }}" style="text-transform:uppercase;">{{ locale }}</a>
{% endif %}
{% endfor %}
{% endblock %}
But this simply shows a single link to the opposite locale than the current. Basically I want to have something like this:
<div id="lang-form">
<div id="language-selected" class="dropdownbox">EN ▾</div>
<div id="dropdown-wrapper">
<ul name="lang" id="select-language-menu" class="menu">
<li class="selected">
English
<div class="lang-code" style="display: none;">en ▾</div>
</li>
<li>
Hungarian
<div class="lang-code" style="display: none;">hu ▾</div>
</li>
</ul>
</div>
</div>
</div>
This probably seems trivial and simple, but I’m having a tough time figuring out how craft works at this level. Any ideas?