|
4 | 4 | {{- $pretty := .pretty -}} |
5 | 5 | {{- $icon := .icon | default "fas globe" -}} |
6 | 6 | {{- $fs := .fs | default 6 -}} |
| 7 | +{{- $inline := site.Params.navigation.language.inline | default false -}} |
| 8 | +{{- $class := cond $inline "inline-menu" "dropdown-menu dropdown-menu-end" }} |
7 | 9 |
|
8 | 10 | {{- $lang := $page.Language.Lang -}} |
9 | 11 | <li class="nav-item dropdown me-auto"> |
10 | | - <a class="nav-link dropdown-toggle d-{{ $breakpoint }}-none" role="button" data-bs-toggle="dropdown" |
11 | | - aria-label="{{ T "languageSwitcherLabel" }}" aria-expanded="false"> |
12 | | - {{- partial "assets/icon.html" (dict "icon" (printf "%s fa-fw" $icon) "spacing" true) }}{{ T "languageSwitcherLabel" }} |
13 | | - </a> |
14 | | - <a class="nav-link dropdown-toggle d-none d-{{ $breakpoint }}-block" role="button" data-bs-toggle="dropdown" |
15 | | - aria-label="{{ T "languageSwitcherLabel" }}" aria-expanded="false"> |
16 | | - {{- partial "assets/icon.html" (dict "icon" (printf "%s fa-fw" $icon) "spacing" false) }} |
17 | | - </a> |
18 | | - <ul id="language-selector" class="dropdown-menu dropdown-menu-end navbar-fs-{{ $fs }} navbar-{{ $breakpoint }}-fs" data-translated="{{ $page.IsTranslated }}"> |
| 12 | + {{ if not $inline }} |
| 13 | + <a class="nav-link dropdown-toggle d-{{ $breakpoint }}-none" role="button" data-bs-toggle="dropdown" |
| 14 | + aria-label="{{ T "languageSwitcherLabel" }}" aria-expanded="false"> |
| 15 | + {{- partial "assets/icon.html" (dict "icon" (printf "%s fa-fw" $icon) "spacing" true) }}{{ T "languageSwitcherLabel" }} |
| 16 | + </a> |
| 17 | + <a class="nav-link dropdown-toggle d-none d-{{ $breakpoint }}-block" role="button" data-bs-toggle="dropdown" |
| 18 | + aria-label="{{ T "languageSwitcherLabel" }}" aria-expanded="false"> |
| 19 | + {{- partial "assets/icon.html" (dict "icon" (printf "%s fa-fw" $icon) "spacing" false) }} |
| 20 | + </a> |
| 21 | + {{ end }} |
| 22 | + <ul id="language-selector" class="{{ $class }} navbar-fs-{{ $fs }} navbar-{{ $breakpoint }}-fs" data-translated="{{ $page.IsTranslated }}"> |
19 | 23 | {{- if $page.IsTranslated -}} |
20 | 24 | {{- range $page.AllTranslations -}} |
21 | 25 | <li> |
22 | 26 | {{- $state := cond (eq .Language.Lang $lang) "active" "" }} |
23 | 27 | <a class="dropdown-item {{ $state }}" hreflang="{{ .Language.Lang }}" href="{{ .RelPermalink }}"> |
24 | | - {{- .Language.LanguageName -}} |
| 28 | + {{- cond $inline (upper .Language.Lang) .Language.LanguageName -}} |
25 | 29 | </a> |
26 | 30 | </li> |
27 | 31 | {{- end -}} |
28 | 32 | {{- else -}} |
29 | 33 | {{- range site.Languages -}} |
30 | | - {{ $dest := partial "utilities/URLJoin.html" (dict "base" $baseURL "path" .Lang) }} |
31 | | - {{ if and $pretty (not (hasSuffix $dest "/")) }} |
32 | | - {{ $dest = printf "%s/" $dest }} |
33 | | - {{ end }} |
34 | | - <li><a class="dropdown-item" href="{{ $dest }}" hreflang="{{ .Lang }}">{{ default .Lang .LanguageName }}</a></li> |
| 34 | + <li> |
| 35 | + {{- $state := cond (eq .Lang $lang) "active" "disabled" }} |
| 36 | + <a class="dropdown-item {{ $state }}" href="{{ cond (eq $state "active") $page.RelPermalink "#!" }}" hreflang="{{ .Lang }}"> |
| 37 | + {{- cond $inline (upper .Lang) (default .Lang .LanguageName) -}} |
| 38 | + </a> |
| 39 | + </li> |
35 | 40 | {{- end -}} |
36 | 41 | {{- end -}} |
37 | 42 | </ul> |
|
0 commit comments