Add a language switcher to the navigation

This ignores whether the current page has a translation in a
given language, but it's a start.
This commit is contained in:
Jack Taylor 2017-04-02 19:01:41 +09:00
parent 0f74f45531
commit 655c2011fe
2 changed files with 26 additions and 0 deletions

View File

@ -25,6 +25,8 @@
# Navigation # Navigation
- id: toggleNavigation - id: toggleNavigation
translation: "Toggle navigation" translation: "Toggle navigation"
- id: languageSwitcherLabel
translation: "Language"
- id: gcseLabelShort - id: gcseLabelShort
translation: "Search" translation: "Search"
- id: gcseLabelLong - id: gcseLabelLong

View File

@ -28,6 +28,30 @@
</li> </li>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if .Site.IsMultiLingual }}
{{ if ge (len .Site.Languages) 3 }}
<li class="navlinks-container">
<a class="navlinks-parent" href="javascript:void(0)">{{ i18n "languageSwitcherLabel" }}</a>
<div class="navlinks-children">
{{ range .Site.Languages }}
{{ if not (eq .Lang $.Site.Language.Lang) }}
<a href="/{{ .Lang }}">{{ default .Lang .LanguageName }}</a>
{{ end }}
{{ end }}
</div>
</li>
{{ else }}
<li>
{{ range .Site.Languages }}
{{ if not (eq .Lang $.Site.Language.Lang) }}
<a href="/{{ .Lang }}">{{ default .Lang .LanguageName }}</a>
{{ end }}
{{ end }}
</li>
{{ end }}
{{ end }}
{{ if isset .Site.Params "gcse" }} {{ if isset .Site.Params "gcse" }}
<li> <li>
<a href="#modalSearch" data-toggle="modal" data-target="#modalSearch" style="outline: none;"> <a href="#modalSearch" data-toggle="modal" data-target="#modalSearch" style="outline: none;">