Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/spech66/bootstrap-bp-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pech <windows@spech.de>2019-09-23 22:09:41 +0300
committerSebastian Pech <windows@spech.de>2019-09-23 22:09:41 +0300
commit60c2af48843868bdf4aceb90fbaac0ac81db5568 (patch)
tree08fb7b9423c39504710cdd4f015d10ecd09d23a7
parent9700424db31f7ef42e89a0fc5c756d8052d41f5f (diff)
Multilingual and i18n support
-rw-r--r--README.md1
-rw-r--r--exampleSite/config.toml12
-rw-r--r--exampleSite/content/post/100-multilang/index.de.md27
-rw-r--r--exampleSite/content/post/100-multilang/index.md27
-rw-r--r--i18n/de.toml21
-rw-r--r--i18n/en.toml21
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/partials/content_card_body.html6
-rw-r--r--layouts/partials/content_card_footer.html4
-rw-r--r--layouts/partials/footer.html8
-rw-r--r--layouts/partials/head.html2
-rw-r--r--layouts/partials/header.html2
-rw-r--r--layouts/partials/i18nlist.html11
-rw-r--r--theme.toml2
14 files changed, 134 insertions, 12 deletions
diff --git a/README.md b/README.md
index 4bf86ea..93b1da6 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,7 @@ Other themes by Sebastian Pech: [Bootstrap-BP](https://github.com/spech66/bootst
- Multiple page templates / archetypes supported
- Icons for Social Media
- Custom css/js
+- Multilingual and i18n support
- ...
## Install the theme
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index a3a6f3b..b8a3980 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -47,6 +47,18 @@ theme="bootstrap-bp-hugo-theme"
# csscdn=["https://fonts.googleapis.com/css?family=Concert+One|Roboto&display=swap"]
+#[languages]
+# [languages.en]
+# languageName = "English"
+# title = "My blog"
+# weight = 1
+# [languages.en.params]
+# [languages.de]
+# languageName = "Deutsch"
+# title = "Mein Blog"
+# weight = 2
+# [languages.de.params]
+
# Sets Social Media icons to appear and link to your account. Value should be your
# username unless otherwise noted.
diff --git a/exampleSite/content/post/100-multilang/index.de.md b/exampleSite/content/post/100-multilang/index.de.md
new file mode 100644
index 0000000..e82ba9c
--- /dev/null
+++ b/exampleSite/content/post/100-multilang/index.de.md
@@ -0,0 +1,27 @@
+---
+title: "Testseite - Deutsch"
+type: post
+date: 2019-08-17T08:59:27+01:00
+publishdate: 2019-08-17
+lastmod: 2019-08-17
+description: "Deutsche Testseite"
+tags:
+ - Code
+ - Lorem ipsum
+ - Test
+ - Table
+ - Quote
+ - Aöäüß
+categories:
+ - Theme
+ - Aöäüß
+menu: main
+---
+
+## Deutsche Testseite
+
+Fames sed morbi magnis euismod id blandit aliquam lacus sem rhoncus mauris dapibus pretium nisi. Dolor consequat odio metus nonummy eleifend condimentum pulvinar sociis tellus enim donec risus laoreet taciti lorem auctor. Urna aenean aliquet. Imperdiet. A mus faucibus.
+
+Posuere sagittis. Neque aptent rutrum elementum phasellus quam leo blandit eu feugiat volutpat, nec condimentum porta nulla feugiat duis mus commodo eget per Libero sit, rhoncus arcu class consequat. Eu mauris porttitor venenatis convallis. Cubilia erat.
+
+Ligula dui nostra. Platea potenti dui ut pellentesque tellus nostra bibendum, ornare dictum sociis ultricies quis elit volutpat mattis placerat, bibendum cras sapien augue dolor.
diff --git a/exampleSite/content/post/100-multilang/index.md b/exampleSite/content/post/100-multilang/index.md
new file mode 100644
index 0000000..94f4adf
--- /dev/null
+++ b/exampleSite/content/post/100-multilang/index.md
@@ -0,0 +1,27 @@
+---
+title: "Testpage - English"
+type: post
+date: 2019-08-17T08:59:27+01:00
+publishdate: 2019-08-17
+lastmod: 2019-08-17
+description: "English testpage"
+tags:
+ - Code
+ - Lorem ipsum
+ - Test
+ - Table
+ - Quote
+ - Aöäüß
+categories:
+ - Theme
+ - Aöäüß
+menu: main
+---
+
+## English testpage
+
+Pretium nam habitant placerat pretium litora suspendisse. Nibh, tellus. Facilisi vitae consectetuer lacus fringilla nulla massa hendrerit. Tincidunt ad. Felis pede ultricies sem Netus. Vehicula, suspendisse. Nisl morbi lacinia sit etiam massa Malesuada class taciti euismod curae; augue quis tristique.
+
+Interdum inceptos cras ornare risus hac. Accumsan sociis metus orci nisi sem. Viverra. Morbi suscipit curabitur nec. Est. Pulvinar in luctus in porttitor. Phasellus Vehicula elementum dictum. Fusce parturient sodales non amet platea, praesent viverra ante. Nec montes sodales sapien vehicula.
+
+Aptent scelerisque netus etiam scelerisque nostra. Tincidunt. Class sagittis tortor. Mattis hac ultrices Dapibus aptent viverra dapibus sagittis pretium.
diff --git a/i18n/de.toml b/i18n/de.toml
new file mode 100644
index 0000000..6bc2522
--- /dev/null
+++ b/i18n/de.toml
@@ -0,0 +1,21 @@
+[readmore]
+other = "Weiterlesen"
+
+[lastupdated]
+other = "zuletzt aktualisiert"
+
+[readingTime]
+one = "1 Minute"
+other = "{{.Count}} Minuten"
+
+[social]
+other = "Sozial"
+
+[site]
+other = "Seite"
+
+[translations]
+other="Übersetzungen"
+
+[themeby]
+other = "Theme von"
diff --git a/i18n/en.toml b/i18n/en.toml
new file mode 100644
index 0000000..8ca46b8
--- /dev/null
+++ b/i18n/en.toml
@@ -0,0 +1,21 @@
+[readmore]
+other = "Read more"
+
+[lastupdated]
+other = "last updated"
+
+[readingTime]
+one = "1 Minute"
+other = "{{.Count}} Minutes"
+
+[social]
+other = "Social"
+
+[site]
+other = "Site"
+
+[translations]
+other="Translations"
+
+[themeby]
+other = "Theme by"
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 4410f89..eaf6438 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en-US{{ end }}">
+<html lang="{{.Site.Language.Lang }}">
<meta charset="utf-8">
{{- partial "seo_schema" . -}}
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
diff --git a/layouts/partials/content_card_body.html b/layouts/partials/content_card_body.html
index 11626f2..9dee915 100644
--- a/layouts/partials/content_card_body.html
+++ b/layouts/partials/content_card_body.html
@@ -4,11 +4,11 @@
<div class="card-body">
<h1 class="card-title"><a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a></h1>
<h6 class="card-subtitle mb-2 text-muted">
- <i class="fas fa-calendar-day"></i>&nbsp;{{ .PublishDate.Format $customDateFormat }}{{ if gt .Lastmod .PublishDate }}, last updated {{ .Lastmod.Format $customDateFormat }}{{ end }} -
+ <i class="fas fa-calendar-day"></i>&nbsp;{{ .PublishDate.Format $customDateFormat }}{{ if gt .Lastmod .PublishDate }}, {{ i18n "lastupdated" }} {{ .Lastmod.Format $customDateFormat }}{{ end }} -
<i class="fas fa-user"></i>&nbsp;{{ range .Site.Author }}{{ . }}{{ end }}
{{ if ne .Site.Params.hideReadingTime true }}
{{ if and (not (.Scratch.Get "showPostSummary")) (.Scratch.Get "fullsize") }}
- - <i class="fas fa-clock"></i>&nbsp;~{{ if le .ReadingTime 1 }}1 Minute{{ else }}{{ .ReadingTime }} Minutes{{ end }}
+ - <i class="fas fa-clock"></i>&nbsp;~{{ i18n "readingTime" .ReadingTime }}
{{ end }}
{{ end }}
</h6>
@@ -27,7 +27,7 @@
{{ if .Scratch.Get "showPostSummary" }}
<p class="card-text">{{ .Summary }}</p>
- <a href="{{ .RelPermalink }}" class="card-link">Read more&hellip;</a>
+ <a href="{{ .RelPermalink }}" class="card-link">{{ i18n "readmore" }}&hellip;</a>
{{ if ne .Site.Params.hideReadingTime true }}
(<i class="fas fa-clock"></i>&nbsp;~{{ .ReadingTime }} Min.)
{{end}}
diff --git a/layouts/partials/content_card_footer.html b/layouts/partials/content_card_footer.html
index 887e024..fc128f7 100644
--- a/layouts/partials/content_card_footer.html
+++ b/layouts/partials/content_card_footer.html
@@ -4,14 +4,14 @@
{{ if gt .Params.categories 0 }}
<i class="fas fa-folder text-primary"></i>&nbsp;
{{ range .Params.categories }}
- <a href="{{ "/categories/" | relURL }}#{{ . | urlize }}" class="badge badge-primary"><span>{{ . }}</span></a>
+ <a href="{{ "/categories/" | relLangURL }}#{{ . | urlize }}" class="badge badge-primary"><span>{{ . }}</span></a>
{{ end }}
<br />
{{ end }}
{{ if gt .Params.tags 0 }}
<i class="fas fa-tags text-secondary"></i>&nbsp;
{{ range .Params.tags }}
- <a href="{{ "/tags/" | relURL }}#{{ . | urlize }}" class="badge badge-secondary"><span>{{ . }}</span></a>
+ <a href="{{ "/tags/" | relLangURL }}#{{ . | urlize }}" class="badge badge-secondary"><span>{{ . }}</span></a>
{{ end }}
{{ end }}
{{ end }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index b6baeaa..5f6db56 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -6,13 +6,13 @@
{{ .Site.Params.description }}
</div>
<div class="col-12 col-md-3 mb-3">
- <h5>Social</h5>
+ <h5>{{ i18n "social" }}</h5>
<ul class="list-unstyled list-inline">
{{- partial "social.html" . -}}
</ul>
</div>
<div class="col-12 col-md-3 mb-3">
- <h5>Site</h5>
+ <h5>{{ i18n "site" }}</h5>
<ul class="list-unstyled">
{{ range $index, $element := .Site.Menus.footer }}
{{ if .HasChildren }}
@@ -27,8 +27,10 @@
</ul>
</div>
<div class="col-12 col-md-3 mb-3">
+ {{ partial "i18nlist.html" . }}
+
&copy; {{ now.Format "2006" }} {{ range .Site.Author }}{{ . }}{{ end }}<br/>
- Theme by <a href="https://www.spech.de">Sebastian Pech</a>.
+ {{ i18n "themeby" }} <a href="https://www.spech.de">Sebastian Pech</a>.
</div>
</div>
</div>
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 383cf5e..d5a5d90 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -10,7 +10,7 @@
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
-{{ if .Site.RSSLink }}<link rel="alternate" href="{{ .Site.RSSLink }}" type="application/rss+xml" title="{{ .Site.Title }}"/>{{ end }}
+{{ if .Site.RSSLink }}<link rel="alternate" href="{{ .Site.RSSLink | relLangURL }}" type="application/rss+xml" title="{{ .Site.Title }}"/>{{ end }}
{{ $themeColor := "default" }}
{{ if .Site.Params.themeColor }}
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index eb6118e..3fcb89a 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -10,7 +10,7 @@
<nav class="navbar {{ $navClasses }} {{ $alwaysExpandMenu }} border-bottom">
<div class="container">
- <a class="navbar-brand text-primary" href="/">{{ .Site.Title }}</a>
+ <a class="navbar-brand text-primary" href="{{ "/" | relLangURL }}">{{ .Site.Title }}</a>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
diff --git a/layouts/partials/i18nlist.html b/layouts/partials/i18nlist.html
new file mode 100644
index 0000000..282ebd1
--- /dev/null
+++ b/layouts/partials/i18nlist.html
@@ -0,0 +1,11 @@
+{{ if .IsTranslated }}
+ <h5>{{ i18n "translations" }}</h5>
+ <ul class="list-unstyled">
+ {{ range .Translations }}
+ <li><a href="{{ .RelPermalink }}">{{ .Title }} ({{ .Lang }})</a></li>
+ {{ end}}
+ {{ range $.Site.Home.AllTranslations }}
+ <li><a href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a></li>
+ {{ end }}
+ </ul>
+{{ end }}
diff --git a/theme.toml b/theme.toml
index 09c270c..c2f7419 100644
--- a/theme.toml
+++ b/theme.toml
@@ -6,7 +6,7 @@ license = "MIT"
licenselink = "https://github.com/spech66/bootstrap-bp-hugo-theme/blob/master/LICENSE"
description = "Bootstrap based Hugo theme which supports out of the box best practices."
homepage = "https://github.com/spech66/bootstrap-bp-hugo-theme/"
-tags = ["minimalist", "minimal", "blog", "clean", "simple", "bootstrap", "responsive", "google analytics", "syntax sighlighting", "light", "fast", "dark", "pages", "font awesome", "fontawesome"]
+tags = ["minimalist", "minimal", "blog", "clean", "simple", "bootstrap", "responsive", "google analytics", "syntax sighlighting", "light", "fast", "dark", "pages", "font awesome", "fontawesome", "multilingual", "customizable", "mobile"]
features = ["responsive", "google analytics", "bootstrap v4.3.x", "open graph", "twitter cards"]
min_version = "0.57"