From ed4a43096c71559b49c92038acb34a3998218148 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Wed, 9 Sep 2020 17:17:09 +0200 Subject: [PATCH] feat(i18n): initial support for i18n --- exampleSite/config.toml | 1 + i18n/en.toml | 23 +++++++++++++++++++ layouts/404.html | 4 ++-- .../partials/article/components/footer.html | 4 +++- .../article/components/related-contents.html | 2 +- layouts/partials/sidebar/left.html | 2 +- layouts/partials/widget/archive.html | 4 ++-- layouts/partials/widget/tag-cloud.html | 2 +- 8 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 i18n/en.toml diff --git a/exampleSite/config.toml b/exampleSite/config.toml index e2ea524..c047d85 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -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/" diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000..dd89621 --- /dev/null +++ b/i18n/en.toml @@ -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." \ No newline at end of file diff --git a/layouts/404.html b/layouts/404.html index 2d4565a..d882c30 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -5,8 +5,8 @@
-

Not Found

-

This page does not exist.

+

{{ T "notFoundTitle" }}

+

{{ T "notFoundSubtitle" }}

diff --git a/layouts/partials/article/components/footer.html b/layouts/partials/article/components/footer.html index 3b281bc..c6f80e5 100644 --- a/layouts/partials/article/components/footer.html +++ b/layouts/partials/article/components/footer.html @@ -17,7 +17,9 @@ {{- if ne .Lastmod .Date -}}
{{ (resources.Get "icons/clock.svg").Content | safeHTML }} - Last updated on {{ .Lastmod.Format ( or .Site.Params.dateFormat "Jan 02, 2006 15:04 MST" ) }} + + {{ T "lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat "Jan 02, 2006 15:04 MST" ) }} +
{{- end -}} \ No newline at end of file diff --git a/layouts/partials/article/components/related-contents.html b/layouts/partials/article/components/related-contents.html index ac85adf..2f3b52c 100644 --- a/layouts/partials/article/components/related-contents.html +++ b/layouts/partials/article/components/related-contents.html @@ -1,7 +1,7 @@