This repository has been archived on 2024-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
fediversity.eu/themes/hugoplate/layouts/partials/components/language-switcher.html

26 lines
837 B
HTML
Raw Normal View History

2024-03-26 16:28:28 +01:00
<!-- Language List -->
2024-03-27 12:24:18 +01:00
{{ $class := .Class }} {{ $context := .Context }} {{ $pageLang := $context.Lang
}} {{ $base:= urls.Parse site.Home.Permalink }} {{ $siteLanguages :=
site.Home.AllTranslations }} {{ $pageLink := replace (replace
$context.RelPermalink (add $pageLang "/") "") $base.Path "/" }} {{ if
$context.IsTranslated }}
<select class="{{ $class }}" onchange="location = this.value">
{{ range $siteLanguages }} {{ if eq (string $pageLang) (string .Language) }}
<option
id="{{ .Language }}"
value="{{ replace (add .RelPermalink $pageLink) `//` `/` }}"
selected
>
{{ .Language.LanguageName }}
</option>
{{ else }}
<option
id="{{ .Language }}"
value="{{ replace (add .RelPermalink $pageLink) `//` `/` }}"
>
{{ .Language.LanguageName }}
</option>
{{ end }} {{ end }}
</select>
2024-03-26 16:28:28 +01:00
{{ end }}