diff options
author | Alex Shpak <alex-shpak@users.noreply.github.com> | 2019-11-10 00:23:06 +0100 |
---|---|---|
committer | Alex Shpak <alex-shpak@users.noreply.github.com> | 2019-11-16 20:35:23 +0100 |
commit | 05c3b8fac9bec7cf54fed20d93fac52e1e97ad97 (patch) | |
tree | 616345b1ec544000d9b3471852ac088bc8df382c /layouts | |
parent | 9cd378a2d27ad4c9cb2e46d12022e68e23f96ea7 (diff) |
Add language switch at bottom of page
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/docs/baseof.html | 2 | ||||
-rw-r--r-- | layouts/partials/docs/footer.html (renamed from layouts/partials/docs/git-footer.html) | 3 | ||||
-rw-r--r-- | layouts/partials/docs/language-switch.html | 14 | ||||
-rw-r--r-- | layouts/partials/docs/languages.html | 32 | ||||
-rw-r--r-- | layouts/partials/docs/menu-filetree.html | 2 | ||||
-rw-r--r-- | layouts/partials/docs/menu.html | 5 | ||||
-rw-r--r-- | layouts/partials/docs/search.html | 2 | ||||
-rw-r--r-- | layouts/partials/docs/translation-switch.html | 14 | ||||
-rw-r--r-- | layouts/posts/baseof.html | 2 |
9 files changed, 38 insertions, 38 deletions
diff --git a/layouts/docs/baseof.html b/layouts/docs/baseof.html index 6ee6e40..38630a7 100644 --- a/layouts/docs/baseof.html +++ b/layouts/docs/baseof.html @@ -17,7 +17,7 @@ <div class="book-page"> {{ partial "docs/mobile-header" . }} {{ template "main" . }} - {{ partial "docs/git-footer" . }} + {{ partial "docs/footer" . }} {{ partial "docs/inject/footer" . }} </div> diff --git a/layouts/partials/docs/git-footer.html b/layouts/partials/docs/footer.html index bf3e4a7..15d1640 100644 --- a/layouts/partials/docs/git-footer.html +++ b/layouts/partials/docs/footer.html @@ -1,5 +1,6 @@ {{ if or .GitInfo .Site.Params.BookEditPath }} <div class="book-footer {{ if not .GitInfo }}justify-end{{ else }}justify-between{{ end }}"> + {{ partial "docs/languages" . }} {{ with .GitInfo }} <div> {{ $date := .AuthorDate.Local.Format (default "January 2, 2006" $.Site.Params.BookDateFormat) }} @@ -14,7 +15,7 @@ {{ if $.File }} <a class="flex align-center" href="{{ $.Site.Params.BookRepo }}/{{ . }}/{{ $.File.Path }}" target="_blank" rel="noopener"> <img src="{{ "svg/edit.svg" | relURL }}" alt="Edit" /> - <span>Edit this page</span> + <span>{{ i18n "Edit this page" }}</span> </a> {{ end }} </div> diff --git a/layouts/partials/docs/language-switch.html b/layouts/partials/docs/language-switch.html deleted file mode 100644 index 4a84ade..0000000 --- a/layouts/partials/docs/language-switch.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ if .Site.IsMultiLingual }} -<ul> - <li class="book-section-flat"> - <span>{{ i18n "languages" }}</span> - <ul> - {{ range .Site.Home.AllTranslations -}} - <li> - <a href="{{ .Permalink }}" class="{{ if (eq $.Site.Language .Language ) }}active{{ end }}">{{ .Language.LanguageName }}</a> - </li> - {{- end }} - </ul> - </li> -</ul> -{{ end }} diff --git a/layouts/partials/docs/languages.html b/layouts/partials/docs/languages.html new file mode 100644 index 0000000..d905327 --- /dev/null +++ b/layouts/partials/docs/languages.html @@ -0,0 +1,32 @@ +{{ if .Site.IsMultiLingual }} +<!-- Merge home and current page translations --> +{{ $langs := dict }} +{{ range .Site.Home.AllTranslations }} + {{ $langs = merge $langs (dict .Language.Lang .) }} +{{ end }} +{{ range .Translations }} + {{ $langs = merge $langs (dict .Language.Lang .) }} +{{ end }} + +<div class="book-languages"> + + <ul> + <li class="flex"> + <img src="{{ "svg/translate.svg" | relURL }}" /> + {{ $.Site.Language.LanguageName }} + </li> + </ul> + + <ul class="book-languages-list"> + {{ range sort $langs }} + <li class="{{ if (eq $.Site.Language .Language ) }}active{{ end }}"> + <a href="{{ .Permalink }}" class="flex"> + <img src="{{ "svg/translate.svg" | relURL }}" /> + {{ .Language.LanguageName }} + </a> + </li> + {{ end }} + </ul> + +</div> +{{ end }} diff --git a/layouts/partials/docs/menu-filetree.html b/layouts/partials/docs/menu-filetree.html index c917828..30fc2ce 100644 --- a/layouts/partials/docs/menu-filetree.html +++ b/layouts/partials/docs/menu-filetree.html @@ -15,7 +15,7 @@ {{ end }} {{ else }} <ul> - {{ range where $sections "Params.bookhidden" "!=" true }} + {{ range where $sections "Params.bookHidden" "!=" true }} {{ template "book-section" (dict "Section" . "CurrentPage" $) }} {{ end }} </ul> diff --git a/layouts/partials/docs/menu.html b/layouts/partials/docs/menu.html index 3d04b04..6a72ac9 100644 --- a/layouts/partials/docs/menu.html +++ b/layouts/partials/docs/menu.html @@ -10,11 +10,6 @@ {{ end }} {{ partial "docs/inject/menu-after" . }} - -{{ if .Site.IsMultiLingual }} - {{ partial "docs/translation-switch" . }} - {{ partial "docs/language-switch" . }} -{{ end }} </nav> <!-- Restore menu position as soon as possible to avoid flickering --> diff --git a/layouts/partials/docs/search.html b/layouts/partials/docs/search.html index 17a14eb..5c8b912 100644 --- a/layouts/partials/docs/search.html +++ b/layouts/partials/docs/search.html @@ -1,6 +1,6 @@ {{ if default true .Site.Params.BookSearch }} <div class="book-search"> - <input type="text" placeholder="Search" id="book-search-input" maxlength="64" /> + <input type="text" placeholder="{{ i18n "Search" }}" id="book-search-input" maxlength="64" /> <div class="book-search-spinner spinner hidden"></div> <ul id="book-search-results"></ul> </div> diff --git a/layouts/partials/docs/translation-switch.html b/layouts/partials/docs/translation-switch.html deleted file mode 100644 index 4ad0f1a..0000000 --- a/layouts/partials/docs/translation-switch.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ if .IsTranslated }} -<ul> - <li class="book-section-flat"> - <span>{{ i18n "translations" }}</span> - <ul> - {{ range .Translations }} - <li> - <a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a> - </li> - {{ end }} - </ul> - </li> -</ul> -{{ end }}
\ No newline at end of file diff --git a/layouts/posts/baseof.html b/layouts/posts/baseof.html index c58d552..9777d48 100644 --- a/layouts/posts/baseof.html +++ b/layouts/posts/baseof.html @@ -17,7 +17,7 @@ <div class="book-posts"> {{ partial "docs/mobile-header" . }} {{ template "main" . }} - {{ partial "docs/git-footer" . }} + {{ partial "docs/footer" . }} {{ partial "docs/inject/footer" . }} </div> |