{{ if .IsTranslated -}}
{{ range .Translations }}
<div class="item">
<a href="{{ .Permalink }}" lang="{{ or (.Site.LanguageCode) (.Site.Language.Lang) }}" class="large-flag" title="{{ .Site.Language.LanguageName }}">{{ site.Params.languageflag }}</a>
</div>
{{ end }}
{{ else }}
{{ range .Site.Languages }}
{{ if not (eq .Lang $.Site.Language.Lang) }}
<div class="item">
<span class="large-flag no-lang" title="{{ .Params.LanguageName }}">{{ site.Params.languageflag }}</span>
</div>
{{ end }}
{{ end }}
{{ end }}
Or,
{{ if .IsTranslated -}}
{{ range .Translations }}
<li><a rel="alternate" href="{{ .RelPermalink }}" hreflang="{{ site.LanguageCode | default .Lang }}" lang="{{ site.LanguageCode | default .Lang }}">{{ .Language.LanguageName }}</a> {{ site.Params.languageflag }} </li>
{{ end -}}
{{ else -}}
{{ range site.Languages -}}
{{ if ne site.Language.Lang .Lang }}
<li><a rel="alternate" href="{{ .Lang | relURL }}" hreflang="{{ .Params.LanguageCode | default .Lang }}" lang="{{ .Params.LanguageCode | default .Lang }}">{{ .LanguageName }}</a> {{ site.Params.languageflag }} </li>
{{ end -}}
{{ end -}}
{{ end -}}
In the old way, we can use something like{{ .Site.Language.Params.languageflag }}, where .Site.Language does the magic.
In the new way, {{ site.Params.languageflag }} is displaying the Page’s current language, do we need to enclose {{ site.Params.languageflag }} in an if-then-else statement?
A language configuration configures a language and (mainly) a Site
So, all config sections on the language config section that also exists on the Site config will be merged into the Site
The above includes Params, so every param in .Site.Params is language specific (to put it simply)
With Hugo 0.112.0 we removed lots of complexity in this area (which is always good) and we may also have broken some sites that relied on some undocumented behaviour that we didn’t think about.