{% trans_default_domain 'contao_exception' %}
{% extends "@ContaoCore/Error/layout.html.twig" %}
{% block title %}
    {{ 'XPT.unavailable'|trans }}
{% endblock %}
{% block matter %}
    <p data-trans="XPT.maintenance">{{ 'XPT.maintenance'|trans }}</p>
{% endblock %}

{% block body_end %}
    <script data-labels="{{ defaultLabels|json_encode() }}">
        (function (n, d) {
            let language = n.language;
            const data = JSON.parse(d.currentScript.dataset.labels);
            function translate(key) {
                if (data[language] === undefined) {
                    language = new Intl.Locale(language).language;
                    if (data[language] === undefined) {
                        return null;
                    }
                }
                if (data[language][key] === undefined) {
                    return null;
                }
                return data[language][key];
            }
            d.querySelectorAll('[data-trans]').forEach(el => {
                let trans = translate(el.dataset.trans);
                if (trans) {
                    el.textContent = trans;
                }
            });
            let trans = translate('title');
            if (trans) {
                d.title = data[language].title;
            }
        })(navigator, document);
    </script>
{% endblock %}
