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

github.com/spech66/materialize-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:47 +0300
committerSebastian Pech <windows@spech.de>2019-09-23 22:09:47 +0300
commit69d20e82b2af4cd439b38d1d653fa1419c6f468e (patch)
tree2f9d2532b138489f98a81077d99daf2092db72ef
parent2185fe717b6e85fda135d07289cbdbcb18fcb1d1 (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.toml24
-rw-r--r--i18n/en.toml24
-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.html9
-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, 140 insertions, 13 deletions
diff --git a/README.md b/README.md
index 3283f68..9a2f793 100644
--- a/README.md
+++ b/README.md
@@ -41,6 +41,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 aaaa95f..00cf6be 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -47,6 +47,18 @@ theme="materialize-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..e32f7be
--- /dev/null
+++ b/i18n/de.toml
@@ -0,0 +1,24 @@
+[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"
+
+[madeby]
+other = "Erstellt mit"
diff --git a/i18n/en.toml b/i18n/en.toml
new file mode 100644
index 0000000..23728cf
--- /dev/null
+++ b/i18n/en.toml
@@ -0,0 +1,24 @@
+[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"
+
+[madeby]
+other = "Made by"
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 410efe5..2f5d1fb 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en{{ end }}">
+<html lang="{{.Site.Language.Lang }}">
<meta http-equiv="Content-Type" content="text/html; 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 fc7a1af..552c6cb 100644
--- a/layouts/partials/content_card_body.html
+++ b/layouts/partials/content_card_body.html
@@ -4,11 +4,11 @@
<div class="card-content">
<h1 class="card-title"><a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a></h1>
<h6 class="grey-text">
- <i class="tiny material-icons">calendar_today</i>&nbsp;{{ .PublishDate.Format $customDateFormat }}{{ if gt .Lastmod .PublishDate }}, last updated {{ .Lastmod.Format $customDateFormat }}{{ end }} -
+ <i class="tiny material-icons">calendar_today</i>&nbsp;{{ .PublishDate.Format $customDateFormat }}{{ if gt .Lastmod .PublishDate }}, {{ i18n "lastupdated" }} {{ .Lastmod.Format $customDateFormat }}{{ end }} -
<i class="tiny material-icons">person</i>&nbsp;{{ range .Site.Author }}{{ . }}{{ end }}
{{ if ne .Site.Params.hideReadingTime true }}
{{ if and (not (.Scratch.Get "showPostSummary")) (.Scratch.Get "fullsize") }}
- - <i class="tiny material-icons">timer</i>&nbsp;~{{ if le .ReadingTime 1 }}1 Minute{{ else }}{{ .ReadingTime }} Minutes{{ end }}
+ - <i class="tiny material-icons">timer</i>&nbsp;~{{ i18n "readingTime" .ReadingTime }}
{{ end }}
{{ end }}
</h6>
@@ -28,7 +28,7 @@
<p>{{ .Summary }}</p>
<p><br />
- <a href="{{ .RelPermalink }}" class="blue waves-effect waves-light btn"><i class="material-icons right">navigate_next</i>Read more</a>
+ <a href="{{ .RelPermalink }}" class="blue waves-effect waves-light btn"><i class="material-icons right">navigate_next</i>{{ i18n "readmore" }}</a>
{{ if ne .Site.Params.hideReadingTime true }}
(<i class="tiny material-icons">timer</i>&nbsp;~{{ .ReadingTime }} Min.)
{{end}}
diff --git a/layouts/partials/content_card_footer.html b/layouts/partials/content_card_footer.html
index 44683dd..4c89a06 100644
--- a/layouts/partials/content_card_footer.html
+++ b/layouts/partials/content_card_footer.html
@@ -3,12 +3,12 @@
{{ if ne .Type "page" }}
{{ if gt .Params.categories 0 }}
{{ range .Params.categories }}
- <a href="{{ "/categories/" | relURL }}#{{ . | urlize }}">+{{ . }}</a>
+ <a href="{{ "/categories/" | relLangURL }}#{{ . | urlize }}">+{{ . }}</a>
{{ end }}
{{ end }}
{{ if gt .Params.tags 0 }}
{{ range .Params.tags }}
- <a href="{{ "/tags/" | relURL }}#{{ . | urlize }}">#{{ . }}</a>
+ <a href="{{ "/tags/" | relLangURL }}#{{ . | urlize }}">#{{ . }}</a>
{{ end }}
{{ end }}
{{ end }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 7c0d459..870aae7 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -6,13 +6,14 @@
<p class="grey-text text-lighten-4">{{ .Site.Params.description }}</p>
</div>
<div class="col l4 s12">
- <h5 class="white-text">Social</h5>
+ <h5 class="white-text">{{ i18n "social" }}</h5>
<ul>
{{- partial "social.html" . -}}
</ul>
</div>
<div class="col l4 s12">
- <h5 class="white-text">Site</h5>
+ {{ partial "i18nlist.html" . }}
+ <h5 class="white-text">{{ i18n "site" }}</h5>
<ul>
{{ range $index, $element := .Site.Menus.footer }}
{{ if .HasChildren }}
@@ -31,8 +32,8 @@
<div class="footer-copyright">
<div class="container">
&copy; {{ now.Format "2006" }} {{ range .Site.Author }}{{ . }}{{ end }}.
- Theme by <a class="orange-text text-lighten-3" href="https://www.spech.de">Sebastian Pech</a>.
- Made by <a class="orange-text text-lighten-3" href="http://materializecss.com">Materialize</a>.
+ {{ i18n "themeby" }} <a class="orange-text text-lighten-3" href="https://www.spech.de">Sebastian Pech</a>.
+ {{ i18n "madeby" }} <a class="orange-text text-lighten-3" href="http://materializecss.com">Materialize</a>.
</div>
</div>
</footer>
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 1425370..64a2ebb 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 edce3f4..71aae3c 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,6 +1,6 @@
<nav class="light-blue lighten-1" role="navigation">
<div class="nav-wrapper container">
- <a id="logo-container" href="/" class="brand-logo">{{ .Site.Title }}</a>
+ <a id="logo-container" href="{{ "/" | relLangURL }}" class="brand-logo">{{ .Site.Title }}</a>
<a href="#" data-target="nav-mobile" class="sidenav-trigger"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
{{ $currentPage := . }}
diff --git a/layouts/partials/i18nlist.html b/layouts/partials/i18nlist.html
new file mode 100644
index 0000000..721e4ea
--- /dev/null
+++ b/layouts/partials/i18nlist.html
@@ -0,0 +1,11 @@
+{{ if .IsTranslated }}
+ <h5>{{ i18n "translations" }}</h5>
+ <ul>
+ {{ range .Translations }}
+ <li><a class="white-text" href="{{ .RelPermalink }}">{{ .Title }} ({{ .Lang }})</a></li>
+ {{ end}}
+ {{ range $.Site.Home.AllTranslations }}
+ <li><a class="white-text" href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a></li>
+ {{ end }}
+ </ul>
+{{ end }}
diff --git a/theme.toml b/theme.toml
index ff6325a..1c7406e 100644
--- a/theme.toml
+++ b/theme.toml
@@ -6,7 +6,7 @@ license = "MIT"
licenselink = "https://github.com/spech66/materialize-bp-hugo-theme/blob/master/LICENSE"
description = "MaterializeCSS based Hugo theme which supports out of the box best practices."
homepage = "https://github.com/spech66/materialize-bp-hugo-theme/"
-tags = ["minimalist", "minimal", "blog", "clean", "simple", "material design", "responsive", "google analytics", "syntax sighlighting", "light", "fast", "dark", "pages", "font awesome", "fontawesome"]
+tags = ["minimalist", "minimal", "blog", "clean", "simple", "material design", "responsive", "google analytics", "syntax sighlighting", "light", "fast", "dark", "pages", "font awesome", "fontawesome", "flexbox", "multilingual", "customizable", "mobile"]
features = ["responsive", "google analytics", "material design", "open graph", "twitter cards"]
min_version = "0.57"