feat: add full i18n. Select desired language in the site automatically

This commit is contained in:
matcornic 2017-07-31 22:32:06 +02:00
parent b2437aad0c
commit 157e3ac512
6 changed files with 116 additions and 13 deletions

View file

@ -1,16 +1,15 @@
- internationalisation -> DOING
- Messages: OK
- Se renseigner pour changer le site selon la locale : TODO
- Selon réponse précédente, peut-être ajouter un bouton pour changer de langue : TODO
- dernier ménage de vieux truc inutiles -> TODO
- sticky bar -> TODO
- récriture doc -> TODO
- créer une section Showcase
- refaire la possibilité d'overrider le style/script/etc -> TODO
- créer des thèmes de base -> TODO
- ajouter Travis pour tester le thème quotidiennement avec les nouvelles versions de Hugo -> TODO
- corriger slider menu qui ne fonctionne plus -> TODO
- Update font awesome -> TODO
- internationalisation -> OK
- Messages: OK
- Ajouter un bouton pour changer de langue : OK
- netlify -> OK
- home page -> OK
- réintégrer la doc dans le même repo -> OK

View file

@ -1,11 +1,12 @@
baseURL = "/"
languageCode = "en-US"
DefaultContentLanguage = "en"
defaultContentLanguage = "en"
title = "Hugo Learn Documentation"
theme = "hugo-theme-learn"
themesdir = "../.."
MetaDataFormat = "yaml"
metaDataFormat = "yaml"
defaultContentLanguageInSubdir= true
[params]
editURL = "https://github.com/matcornic/hugo-theme-learn/edit/master/docs/content/"
@ -17,3 +18,15 @@ MetaDataFormat = "yaml"
[outputs]
home = [ "HTML", "RSS", "JSON"]
[Languages]
[Languages.en]
title = "Documentation for Hugo Learn Theme"
weight = 1
languageName = "English"
[Languages.fr]
title = "Documentation du thème Hugo Learn"
weight = 2
languageName = "Français"

View file

@ -0,0 +1,11 @@
---
title: Prérequis
weight: 10
disableToc: true
---
Grâce à la simplicité d'Hugo, cette page est vide car il n'y a quasi pas de prérequis pour utiliser le thème.
Téléchargez le binaire [Hugo](https://gohugo.io/getting-started/installing/) pour votre Système d'exploitation (Windows, Linux, Mac) : et c'est tout !
![Magic](/basics/requirements/images/magic.gif?classes=shadow)

View file

@ -6,6 +6,6 @@ disableToc: true
Thanks to the simplicity of Hugo, this page is as empty as this theme needs requirements.
Just download [Hugo](https://gohugo.io/overview/installing/) binary for your OS (Windows, Linux, Mac) : it's that simple.
Just download [Hugo](https://gohugo.io/getting-started/installing/) binary for your OS (Windows, Linux, Mac) : it's that simple.
![Magic](/basics/requirements/images/magic.gif?classes=shadow)

View file

@ -25,10 +25,49 @@
{{end}}
</ul>
<hr/>
{{ if $showvisitedlinks}}
<a class="padding" href="#" data-clear-history-toggle=""><i class="fa fa-fw fa-history"></i> {{T "Clear-History"}}</a>
{{ end }}
<section id="prefooter">
<ul>
{{ if .Site.IsMultiLingual }}
<li>
<a class="padding">
<i class="fa fa-fw fa-language"></i>
<div class="select-style">
<select id="select-language" onchange="location = this.value;">
{{ $siteLanguages := .Site.Languages}}
{{ $pageLang := .Page.Lang}}
{{ range .Page.AllTranslations }}
{{ $translation := .}}
{{ range $siteLanguages }}
{{ if eq $translation.Lang .Lang }}
{{ $selected := false }}
{{ if eq $pageLang .Lang}}
<option id="{{ $translation.Language }}" value="{{ $translation.URL }}" selected>{{ .LanguageName }}</option>
{{ else }}
<option id="{{ $translation.Language }}" value="{{ $translation.URL }}">{{ .LanguageName }}</option>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</select>
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="255px" height="255px" viewBox="0 0 255 255" style="enable-background:new 0 0 255 255;" xml:space="preserve">
<g>
<g id="arrow-drop-down">
<polygon points="0,63.75 127.5,191.25 255,63.75 " />
</g>
</g>
</svg>
</div>
</a>
</li>
{{end}}
{{ if $showvisitedlinks}}
<li><a class="padding" href="#" data-clear-history-toggle=""><i class="fa fa-fw fa-history"></i> {{T "Clear-History"}}</a></li>
{{ end }}
</ul>
</section>
<section id="footer">
{{ partial "menu-footer.html" . }}
</section>

View file

@ -208,4 +208,45 @@ figcaption h4 {
font-size: 1em;
text-align: center;
margin-top: -1.5em;
}
.select-style {
border: 0;
width: 150px;
border-radius: 0px;
overflow: hidden;
display: inline-flex;
}
.select-style svg {
fill: #ccc;
width: 14px;
height: 14px;
pointer-events: none;
margin: auto;
}
.select-style svg:hover {
fill: #e6e6e6;
}
.select-style select {
padding: 0;
width: 130%;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
margin: auto;
margin-left: 0px;
margin-right: -20px;
}
.select-style select:focus {
outline: none;
}
.select-style :hover {
cursor: pointer;
}