{%- if section.translations -%}
    {%- set current_translations = section.translations -%}
{%- elif page.translations -%}
    {%- set current_translations = page.translations -%}
{%- endif -%}

{%- if current_translations -%}

    {%- for translation in current_translations -%}
        {%- set lcode = translation.lang | default(value = config.default_language) -%}

        {#- Dynamically load the language strings for each language -#}
        {%- set other_language_strings = load_data(path="i18n/" ~ lcode ~ ".toml", required=false) -%}
        {%- if not other_language_strings -%}
            {%- set other_language_strings = load_data(path="themes/tabi/i18n/" ~ lcode ~ ".toml", required=false) -%}
        {%- endif -%}
        <meta property="og:locale:alternate" content="{{ macros_translate::translate(key="date_locale", default="en_GB", language_strings=other_language_strings) }}" />

        {# Construct href for hreflang #}
        {%- set href = translation.permalink -%}
        {%- if lcode == config.default_language -%}
            {%- set href = href | replace(from='/' ~ lang ~ '/', to = '/') -%}
        {%- else -%}
            {%- set href = href | replace(from='/' ~ lang ~ '/', to='/' ~ lcode ~ '/') -%}
        {%- endif -%}
        <link rel="alternate" hreflang="{{ lcode }}" href="{{ href | safe }}" />
    {%- endfor -%}

{%- endif -%}
