<?xml version="1.0"?>
<data inherit_id="portal.language_selector">
    <xpath expr="//t[@t-nocache]" position="attributes">
        <attribute name="t-nocache-flags">flags</attribute>
    </xpath>

    <xpath expr="//t[@t-set='active_lang']" position="before">
        <t t-if="lang not in (lg[0] for lg in languages)">
            <t t-set="lang" t-value="website.default_lang_id.code"/>
        </t>
    </xpath>

    <!-- Always show the language selector on editable websites -->
    <xpath expr="//t[@t-set='language_selector_visible']" position="after">
        <t t-set="language_selector_visible" t-value="language_selector_visible or (website and (editable or translatable))"/>
    </xpath>

    <!-- Add the button to add a language -->
    <xpath expr="//t[@t-foreach='languages']" position="after">
        <t t-call="website.language_selector_add_language">
            <t t-set="dropdown" t-value="True"/>
        </t>
    </xpath>

    <!-- Add the 'flags' possibility -->
    <xpath expr="//button[contains(@t-attf-class, 'dropdown-toggle')]/span" position="before">
        <t t-if="flags" t-call="website.lang_flag">
            <t t-set="flag_image_src" t-value="active_lang[4]"/>
        </t>
    </xpath>
    <xpath expr="//*[contains(@t-attf-class, 'js_change_lang')]/span" position="before">
        <t t-if="flags" t-call="website.lang_flag">
            <t t-set="flag_image_src" t-value="lg[4]"/>
        </t>
    </xpath>
</data>

