feat(i18n): initial support for i18n

This commit is contained in:
Jimmy Cai 2020-09-09 17:17:09 +02:00
parent 98804e578d
commit ed4a43096c
No known key found for this signature in database
GPG Key ID: 3EA408E527F37B18
8 changed files with 34 additions and 8 deletions

View File

@ -4,6 +4,7 @@ theme = "hugo-theme-stack"
paginate = 5
title = "Example Site"
disqusShortname = "hugo-theme-stack" # Change it to your Disqus shortname before using
DefaultContentLanguage = "en" # Theme i18n support
[permalinks]
post = "/p/:slug/"

23
i18n/en.toml Normal file
View File

@ -0,0 +1,23 @@
[toggleMenu]
other = "Toggle Menu"
[relatedContents]
other = "Related contents"
[lastUpdatedOn]
other ="Last updated on "
[widgetArchiveTitle]
other = "Archive"
[widgetArchiveMore]
other = "More"
[widgetTagCloudTitle]
other = "Tags"
[notFoundTitle]
other = "Not Found"
[notFoundSubtitle]
other = "This page does not exist."

View File

@ -5,8 +5,8 @@
<main class="main full-width">
<div class="not-found-card">
<h1 class="article-title">Not Found</h1>
<h2 class="article-subtitle">This page does not exist.</h2>
<h1 class="article-title">{{ T "notFoundTitle" }}</h1>
<h2 class="article-subtitle">{{ T "notFoundSubtitle" }}</h2>
</div>
</main>
</div>

View File

@ -17,7 +17,9 @@
{{- if ne .Lastmod .Date -}}
<section class="article-time">
{{ (resources.Get "icons/clock.svg").Content | safeHTML }}
<span class="article-time--modified">Last updated on {{ .Lastmod.Format ( or .Site.Params.dateFormat "Jan 02, 2006 15:04 MST" ) }}</span>
<span class="article-time--modified">
{{ T "lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat "Jan 02, 2006 15:04 MST" ) }}
</span>
</section>
{{- end -}}
</footer>

View File

@ -1,7 +1,7 @@
<aside class="widget related-contents--wrapper">
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
<h1 class="widget-title">Related contents</h1>
<h1 class="widget-title">{{ T "relatedContents" }}</h1>
<div class="related-contents">
<div class="flex article-list--tile">
{{ range . }}

View File

@ -1,5 +1,5 @@
<aside class="sidebar left-sidebar sticky">
<button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="Toggle Menu">
<button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="{{ T `toggleMenu` }}">
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>

View File

@ -2,7 +2,7 @@
<div class="widget-icon">
{{ (resources.Get "icons/infinity.svg").Content | safeHTML }}
</div>
<h1 class="widget-title">Archive</h1>
<h1 class="widget-title">{{ T "widgetArchiveTitle" }}</h1>
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
@ -22,7 +22,7 @@
{{ if gt (len $archive) .Site.Params.widgets.archive.limit }}
<div class="archive-year">
<a href="{{ $.Site.BaseURL }}/archive">
<span class="year">More</span>
<span class="year">{{ T "widgetArchiveMore" }}</span>
</a>
</div>
{{ end }}

View File

@ -5,7 +5,7 @@
<div class="widget-icon">
{{ (resources.Get "icons/tag.svg").Content | safeHTML }}
</div>
<h1 class="widget-title">Tags</h1>
<h1 class="widget-title">{{ T "widgetTagCloudTitle" }}</h1>
<div class="tagCloud-tags">
{{ range first .Site.Params.widgets.tagCloud.limit $v2 }}