I have this dropdown language chooser in my header:
<nav>
...
<div class="dropdown" style="position: absolute; float: right; top: 0; right: 0;">
<button class="btn btn-secondary dropdown-toggle" id="dropdownLanguages" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-globe fa-lg" aria-hidden="true"></i>
</button>
<base href="{{ .Site.BaseURL }}">
{{- $language := .Language -}}
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownLanguages">
{{ range .Site.Home.AllTranslations }}
{{ if eq $language .Language }}
<li class="nav-item">
<a class="nav-link active" href="{{ .Permalink }}">
{{ $flag := printf "<img src=\"imgs/flag.%s.svg\">" .Language | safeHTML }}
{{ $flag }}
</a>
</li>
{{ else }}
<li class="nav-item">
<a class="nav-link" href="{{ .Permalink }}">
{{ $flag := printf "<img src=\"imgs/flag.%s.svg\">" .Language | safeHTML }}
{{ $flag }}
</a>
</li>
{{ end }}
{{ end }}
</ul>
</div>
</nav>
However, whenever I’m on a local page in a language (say Italian) and I click on a different language (say English) from this dropdown, it leads me to the home page of that language (English). What am I doing wrong?