Add a multilingual section to the README.

This commit is contained in:
Fredrik Jonsson 2018-03-09 15:58:21 +01:00
commit d3cccf8148
2 changed files with 22 additions and 6 deletions

View file

@ -29,7 +29,7 @@ The [old branch](https://github.com/frjo/hugo-theme-zen/tree/old) has the origin
## Sites using the Hugo Zen theme
* [Combonetwork development](https://combonet.se/)
* [Combonetwork development](https://combonet.se/) (multilingual)
* [Drejargården](https://www.drejargarden.se/)
* [Helmer Grundström](https://www.helmergrundstrom.se/)
* [xdeb.org](https://xdeb.org/)
@ -96,6 +96,27 @@ params:
```
## Multilingual
English and Swedish translations are included and you can easily add more to the `i18n` site directory.
A language selector will be included on sites with more than one language. Add a `LanguageName` parameter to your language configuration, this is what will be displayed in the selector.
The language selector will link to a translation of the current page if it exist and to the front page if it does not.
```
languages:
sv:
weight: 1
params:
LanguageName: "Svenska"
en:
weight: 2
params:
LanguageName: "English"
```
## Contact form
If your server support php with the mail() command (very common) you can use the included contact form feature to get a contact form for your site.

View file

@ -1,21 +1,16 @@
<h2 class="visually-hidden">{{ i18n "lang_select_title" }}</h2>
<nav class="language-selector layout__language-selector" role="navigation">
<ul class="navbar">
{{ if .IsTranslated -}}
{{ range .Translations }}
<li><a rel="alternate" href="{{ .RelPermalink }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .Site.Language.Params.LanguageName }}</a></li>
{{ end -}}
{{ else -}}
{{ range .Site.Languages -}}
{{ if ne $.Site.Language.Lang .Lang }}
<li><a rel="alternate" href="/{{ .Lang }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .Params.LanguageName }}</a></li>
{{ end -}}
{{ end -}}
{{ end -}}
</ul>
</nav>