Merge pull request #818 from h-enk/multilingual

Better multilingual support
This commit is contained in:
Henk Verlinde 2022-07-07 13:08:27 +02:00 committed by GitHub
commit 07e7de6aa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 59 additions and 14 deletions

View File

@ -413,6 +413,11 @@ button#doks-versions {
.btn-menu {
margin-left: 1rem;
border: transparent;
}
.btn-doks-light {
border: transparent;
}
.btn-menu,
@ -426,12 +431,15 @@ button#doks-versions {
.btn-doks-light:hover,
.doks-sidebar-toggle:hover {
background: $pink-100;
border: transparent;
}
.btn-menu:focus,
.btn-doks-light:focus,
.doks-sidebar-toggle:focus,
.doks-mode-toggle:focus {
outline: 0;
border: transparent;
}
.doks-sidebar-toggle .doks-collapse,

View File

@ -5,7 +5,6 @@ disableHugoGeneratorInject = true
enableEmoji = true
enableGitInfo = false
enableRobotsTXT = true
languageCode = "en-US"
paginate = 7
rssLimit = 10

View File

@ -4,6 +4,7 @@
weight = 10
[en.params]
languageISO = "EN"
languageTag = "en-US"
[de]
languageName = "German"
@ -11,6 +12,7 @@
weight = 15
[de.params]
languageISO = "DE"
languageTag = "de-DE"
[nl]
languageName = "Nederlands"
@ -18,6 +20,7 @@
weight = 20
[nl.params]
languageISO = "NL"
languageTag = "nl-NL"
titleAddition = "Modern documentatie-thema"
description = "Doks is een Hugo-thema waarmee je moderne documentatie-websites kunt bouwen die veilig, snel en klaar voor SEO zijn — standaard."
titleHome = "Doks thema"

5
i18n/de.yaml Normal file
View File

@ -0,0 +1,5 @@
- id: get-started
translation: "Loslegen"
- id: on-this-page
translation: "Auf dieser Seite"

View File

@ -1,2 +0,0 @@
[get-started]
other = "Get Started"

17
i18n/en.yaml Normal file
View File

@ -0,0 +1,17 @@
- id: get-started
translation: "Get Started"
- id: on-this-page
translation: "On this page"
- id: search-text
translation: "Search docs..."
- id: 404-title
translation: "Page not found :("
- id: 404-text
translation: "The page you are looking for doesn't exist or has been moved."
- id: browse
translation: "Browse"

View File

@ -1,2 +0,0 @@
[get-started]
other = "Aan de slag"

17
i18n/nl.yaml Normal file
View File

@ -0,0 +1,17 @@
- id: get-started
translation: "Aan de slag"
- id: on-this-page
translation: "Op deze pagina"
- id: search-text
translation: "Zoeken..."
- id: 404-title
translation: "Pagina niet gevonden :("
- id: 404-text
translation: "De gezochte pagina bestaat niet of deze is verplaatst."
- id: browse
translation: "Browse"

View File

@ -2,8 +2,8 @@
<div class="row justify-content-center">
<div class="col-md-12 col-lg-10 col-xl-8">
<article>
<h1 class="text-center">Page not found :(</h1>
<p class="text-center">The page you are looking for doesn't exist or has been moved.</p>
<h1 class="text-center">{{ i18n "404-title" }}</h1>
<p class="text-center">{{ i18n "404-text" }}</p>
</article>
</div>
</div>

View File

@ -1,5 +1,5 @@
<!doctype html>
<html lang="{{ .Site.LanguageCode | default "en" }}">
<html lang="{{ .Site.Params.languageTag | default "en-US" }}">
{{ partial "head/head.html" . }}
{{ if eq .Kind "home" -}}
{{ .Scratch.Set "class" "home" -}}

View File

@ -6,7 +6,7 @@
</div>
<div class="col-lg-9 col-xl-8 text-center">
<p class="lead">{{ .Params.lead | safeHTML }}</p>
<a class="btn btn-primary btn-lg px-4 mb-2" href="/docs/{{ if .Site.Params.options.docsVersioning }}{{ .Site.Params.docsVersion }}/{{ end }}prologue/introduction/" role="button">Get Started</a>
<a class="btn btn-primary btn-lg px-4 mb-2" href="/docs/{{ if .Site.Params.options.docsVersioning }}{{ .Site.Params.docsVersion }}/{{ end }}prologue/introduction/" role="button">{{ i18n "get-started" }}</a>
<p class="meta">Open-source MIT Licensed. <a href="https://github.com/h-enk/doks">GitHub v{{ $data := getJSON "/package.json" }}{{ $data.version }}</a></p>
</div>
</div>

View File

@ -22,7 +22,7 @@
<div class="offcanvas offcanvas-start d-lg-none" tabindex="-1" id="offcanvasExample" aria-labelledby="offcanvasExampleLabel">
<div class="header-bar"></div>
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasExampleLabel">Browse {{ .Section }}</h5>
<h5 class="offcanvas-title" id="offcanvasExampleLabel">{{ i18n "browse" }} {{ .Section }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
@ -87,7 +87,7 @@
{{ if $showFlexSearch -}}
<hr class="text-black-50 my-4 d-lg-none">
<form class="doks-search position-relative flex-grow-1 ms-lg-auto me-lg-2">
<input id="search" class="form-control is-search" type="search" placeholder="Search docs..." aria-label="Search docs..." autocomplete="off">
<input id="search" class="form-control is-search" type="search" placeholder="{{ i18n "search-text" }}" aria-label="{{ i18n "search-text" }}" autocomplete="off">
<div id="suggestions" class="shadow bg-white rounded d-none"></div>
</form>
{{ end -}}

View File

@ -1,7 +1,7 @@
{{ if and (ne .Params.toc false) (ne .TableOfContents "<nav id=\"TableOfContents\"></nav>") -}}
<div class="d-xl-none">
<button class="btn btn-outline-primary btn-sm doks-toc-toggle collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#onThisPage" aria-controls="doks-docs-nav" aria-expanded="false" aria-label="Toggle On this page navigation">
<span>On this page</span>
<span>{{ i18n "on-this-page" }}</span>
<span>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" class="doks doks-expand" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Expand</title><polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" class="doks doks-collapse" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Collapse</title><polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline></svg>
@ -16,7 +16,7 @@
</div>
</div>
<div class="page-links d-none d-xl-block">
<h3>On this page</h3>
<h3>{{ i18n "on-this-page" }}</h3>
{{ if eq .Site.Params.options.scrollSpy true -}}
{{ .TableOfContents | replaceRE "<nav id=\"TableOfContents\">" "<nav id=\"toc\">" | safeHTML }}
{{ else -}}

View File

@ -4,7 +4,7 @@
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<generator>Hugo -- gohugo.io</generator>{{ with .Site.Params.languageTag | default "en-US" }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Params.copyRight }}