{% if languages|length > 1 %}
	<div class="btn-group">
		<button class="btn btn-light dropdown-toggle p-1 px-sm-2" data-toggle="dropdown" aria-label="Language">
			<span class="row no-gutters align-items-start">
				<span class="col-auto mx-2 mx-lg-0">
					<svg class="d-block ft-icon-18 text-gray-500 darker-on-hover" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
						<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"/>
					</svg>
				</span>
				{% for language in languages %}
					{% if language.code == code %}
						<span class="col-auto d-none d-lg-block ml-2 mr-1">
							{{ language.name }}
						</span>
					{% endif %}
				{% endfor %}
				<span class="col-auto d-none d-lg-block">
					<svg class="d-block ft-icon-24 text-gray-500 darker-on-hover" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
						<path transform="translate(0 2)" d="M7.41 7.84L12 12.42l4.59-4.58L18 9.25l-6 6-6-6z"/>
					</svg>
				</span>
			</span>
		</button>
		<div class="dropdown-menu">
			<form action="{{ action }}" method="post" enctype="multipart/form-data" id="ft-form-language">
				{% for language in languages %}
					{% if language.code != code %}
						{% if language.main %}
							<a href="{{ language.url }}" class="dropdown-item language-select" onclick="lm_deleteCookie('languageauto');  window.location = '{{ language.url }}'">
							{% else %}
								<a href="{{ language.url }}" class="dropdown-item language-select" onclick="lm_setCookie('languageauto', '1', {expires: 180}); window.location = '{{ language.url }}'">
								{% endif %}
								{{ language.name }}
							</a>
						{% else %}
							<span class="dropdown-item d-lg-none font-weight-bold">
								{{ language.name }}
							</span>
						{% endif %}
					{% endfor %}

				</form>
			</div>
<script>
function lm_setCookie(name, value, options = {}) {
	options = {
	path: '/',
	...options
	};

	let date = new Date(Date.now() + (86400e3 * options.expires));
	date = date.toUTCString();
	options.expires = date;

	let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);

	for (let optionKey in options) {
		updatedCookie += "; " + optionKey;
		let optionValue = options[optionKey];
		if (optionValue !== true) {
			updatedCookie += "=" + optionValue;
		}
	}
	document.cookie = updatedCookie;
}

function lm_deleteCookie(name) {
	lm_setCookie(name, "", {'max-age': -1});
}
</script>
		</div>
	{% endif %}
