Skip to content

Commit

Permalink
feat(i18n): Add multiple languages support
Browse files Browse the repository at this point in the history
Now this theme supports multiple languages.

See also: https://gohugo.io/content-management/multilingual/
  • Loading branch information
gundamew committed Aug 1, 2019
1 parent 3fb3ab1 commit 94449ca
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ ul {
font-weight: normal;
}

.lang-selector {
display: flex;
align-items: center;
justify-content: space-evenly;
}

.footer-text {
font-size: .8rem;
}
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[recent_posts]
other = "Recent Posts"
2 changes: 2 additions & 0 deletions i18n/zh.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[recent_posts]
other = "最新文章"
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>

<div id="recent-posts">
<h2>Recent Posts</h2>
<h2>{{ i18n "recent_posts" }}</h2>
<ul>
{{ range first 5 .Data.Pages.ByPublishDate.Reverse }}
<li>
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<footer>
{{ partial "lang-selector.html" . }}
<span class="footer-text">Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a></span>
</footer>
{{ $highlight := resources.Get "js/highlight.pack.js" | fingerprint }}
Expand Down
5 changes: 5 additions & 0 deletions layouts/partials/lang-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="lang-selector">
{{ range $.Site.Home.AllTranslations }}
<li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li>
{{ end }}
</ul>

0 comments on commit 94449ca

Please sign in to comment.