diff options
author | Bing-Sheng Chen <gundamew@gmail.com> | 2019-08-01 07:13:51 +0300 |
---|---|---|
committer | Bing-Sheng Chen <gundamew@gmail.com> | 2019-08-01 07:13:51 +0300 |
commit | 94449ca9fa5e1c659c5d1009bf2e2316cb5df284 (patch) | |
tree | f9c02465735f0d2ae4c23ed7f6609eeab2f28b10 | |
parent | 3fb3ab1438887ca01c5fe5fb0e55ee2d1d716dc1 (diff) |
feat(i18n): Add multiple languages supportv1.6.0
Now this theme supports multiple languages.
See also: https://gohugo.io/content-management/multilingual/
-rw-r--r-- | assets/css/style.css | 6 | ||||
-rw-r--r-- | i18n/en.toml | 2 | ||||
-rw-r--r-- | i18n/zh.toml | 2 | ||||
-rw-r--r-- | layouts/index.html | 2 | ||||
-rw-r--r-- | layouts/partials/footer.html | 1 | ||||
-rw-r--r-- | layouts/partials/lang-selector.html | 5 |
6 files changed, 17 insertions, 1 deletions
diff --git a/assets/css/style.css b/assets/css/style.css index ef22d7f..dfa176a 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -163,6 +163,12 @@ ul { font-weight: normal; } +.lang-selector { + display: flex; + align-items: center; + justify-content: space-evenly; +} + .footer-text { font-size: .8rem; } diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000..c21e86d --- /dev/null +++ b/i18n/en.toml @@ -0,0 +1,2 @@ +[recent_posts] +other = "Recent Posts" diff --git a/i18n/zh.toml b/i18n/zh.toml new file mode 100644 index 0000000..617a85e --- /dev/null +++ b/i18n/zh.toml @@ -0,0 +1,2 @@ +[recent_posts] +other = "最新文章" diff --git a/layouts/index.html b/layouts/index.html index de56fcd..6f45c08 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -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> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6cf14a2..f6635c5 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -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 }} diff --git a/layouts/partials/lang-selector.html b/layouts/partials/lang-selector.html new file mode 100644 index 0000000..a2bd9fb --- /dev/null +++ b/layouts/partials/lang-selector.html @@ -0,0 +1,5 @@ +<ul class="lang-selector"> + {{ range $.Site.Home.AllTranslations }} + <li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li> + {{ end }} +</ul> |