website/themes/hugoplate/layouts/partials/components/language-switcher.html

14 lines
525 B
HTML
Raw Normal View History

<!-- Language Switcher -->
{{ $current := .Context }}
2024-02-14 16:01:14 +00:00
{{ $class := .Class }}
{{ if $current.IsTranslated }}
2024-02-14 16:01:14 +00:00
<select class="{{ $class }}" onchange="location = this.value">
{{/* Current page language */}}
<option value="{{ $current.Permalink }}" selected>{{ $current.Language.LanguageName }}</option>
{{/* Iterate over all translations of the current page */}}
{{ range $current.Translations }}
<option value="{{ .Permalink }}">{{ .Language.LanguageName }}</option>
2024-02-14 16:01:14 +00:00
{{ end }}
</select>
{{ end }}