mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-11-24 21:20:17 +01:00
Use i18n to translate some strings
Hugo 0.17 allows for easy multi-lingual sites. Strings can be translated either in the theme or in the site, and missing strings will fall back to the default language. See: https://github.com/spf13/hugo/blob/master/docs/content/content/multilingual.md
This commit is contained in:
parent
d098836949
commit
577e168da5
14
i18n/en.yaml
Normal file
14
i18n/en.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- id: about
|
||||||
|
translation: "About"
|
||||||
|
|
||||||
|
- id: recentPosts
|
||||||
|
translation: "Recent Posts"
|
||||||
|
|
||||||
|
- id: readMore
|
||||||
|
translation: "Read more"
|
||||||
|
|
||||||
|
- id: translations
|
||||||
|
translation: "Translations"
|
||||||
|
|
||||||
|
- id: share
|
||||||
|
translation: "Share"
|
@ -8,7 +8,7 @@
|
|||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
|
||||||
{{ if .IsTranslated }}
|
{{ if .IsTranslated }}
|
||||||
<h4>Translations</h4>
|
<h4>{{ i18n "translations" }}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{{ range .Translations }}
|
{{ range .Translations }}
|
||||||
<li>
|
<li>
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by {{ .Params.author | default .Site.Params.author }}{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
|
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by {{ .Params.author | default .Site.Params.author }}{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
|
||||||
</header>
|
</header>
|
||||||
{{ .Summary }}
|
{{ .Summary }}
|
||||||
<a href='{{ .Permalink }}'>Read more →</a>
|
<a href='{{ .Permalink }}'>{{ i18n "readMore" }} →</a>
|
||||||
</article> <!-- /.blog-post -->
|
</article> <!-- /.blog-post -->
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<footer>
|
<footer>
|
||||||
<header>
|
<header>
|
||||||
<h4>Share</h4>
|
<h4>{{ i18n "share" }}</h4>
|
||||||
</header>
|
</header>
|
||||||
<nav class="nav nav-inline">
|
<nav class="nav nav-inline">
|
||||||
{{ if not (eq .Site.Params.sharingicons.facebook false) }}<a class="nav-item" href="https://www.facebook.com/sharer/sharer.php?u={{ .Permalink }}" title="Share on Facebook"><span class="fa fa-facebook fa-2x" aria-hidden="true"></span></a>{{ end }}
|
{{ if not (eq .Site.Params.sharingicons.facebook false) }}<a class="nav-item" href="https://www.facebook.com/sharer/sharer.php?u={{ .Permalink }}" title="Share on Facebook"><span class="fa fa-facebook fa-2x" aria-hidden="true"></span></a>{{ end }}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<aside class="col-sm-3 offset-sm-1 blog-sidebar">
|
<aside class="col-sm-3 offset-sm-1 blog-sidebar">
|
||||||
{{ if isset .Site.Params.sidebar "about" }}
|
{{ if isset .Site.Params.sidebar "about" }}
|
||||||
<section class="sidebar-module sidebar-module-inset">
|
<section class="sidebar-module sidebar-module-inset">
|
||||||
<h4>About</h4>
|
<h4>{{ i18n "about" }}</h4>
|
||||||
<p>{{ .Site.Params.sidebar.about | markdownify }}</p>
|
<p>{{ .Site.Params.sidebar.about | markdownify }}</p>
|
||||||
</section>
|
</section>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@ -9,7 +9,7 @@
|
|||||||
{{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }}
|
{{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }}
|
||||||
|
|
||||||
<section class="sidebar-module">
|
<section class="sidebar-module">
|
||||||
<h4>Recent Posts</h4>
|
<h4>{{ i18n "recentPosts" }}</h4>
|
||||||
<ol class="list-unstyled">
|
<ol class="list-unstyled">
|
||||||
{{ range first $num_recent_posts (where .Site.Pages "Type" "post") }}
|
{{ range first $num_recent_posts (where .Site.Pages "Type" "post") }}
|
||||||
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
|
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user