<tal:language
    tal:define="available view/available;
                languages view/languages;
                showFlags view/showFlags;">
    <ul id="portal-languageselector"
        tal:condition="python:available and len(languages)>=2">

        <li tal:condition="showFlags"
            tal:repeat="lang languages">
            <span tal:define="code lang/code;
                              selected lang/selected"
                  tal:omit-tag="selected">

                <a href=""
                   tal:define="flag lang/flag;
                               name lang/name"
                   tal:attributes="href string:${here/absolute_url}/switchLanguage?set_language=${code};
                                   title name">
                    <tal:flag condition="flag">
                        <img width="14"
                             height="11"
                             alt=""
                             tal:attributes="src string:${view/portal_url}${flag};
                                             title python: name;
                                             class python: selected and 'currentItem' or '';" />
                    </tal:flag>
                    <tal:nonflag condition="not: flag">
                        <span tal:replace="code">language code</span>
                    </tal:nonflag>
                </a>

            </span>
        </li>

        <li tal:condition="not: showFlags">
            <select style="font-size: 94%;"
                    onchange=""
                    tal:attributes="onchange string:window.location='${context/absolute_url}/switchLanguage?set_language=' + this.options[this.selectedIndex].value">
                <option tal:repeat="lang languages"
                        tal:content="lang/name"
                        tal:attributes="selected lang/selected;
                                        value lang/code">Language</option>
            </select>
        </li>

    </ul>
</tal:language>