From 8711c169be1a680f83f35ed362c10776a5a6abc8 Mon Sep 17 00:00:00 2001 From: Track3 Date: Fri, 14 Dec 2018 15:17:48 +0800 Subject: [PATCH] Add i18n support for translation of strings * Also add Simplified Chinese translations * See #3 --- exampleSite/config.toml | 1 + i18n/en.toml | 24 ++++++++++++++++++++++++ i18n/zh-hans.toml | 24 ++++++++++++++++++++++++ layouts/404.html | 6 +++--- layouts/posts/single.html | 8 ++++---- 5 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 i18n/en.toml create mode 100644 i18n/zh-hans.toml diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 683622a..93b6d81 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -1,5 +1,6 @@ baseURL = "https://example.com" languageCode = "en-us" +defaultContentLanguage = "en" title = "Hugo Hermit" theme = "hermit" # enableGitInfo = true diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000..b3316f3 --- /dev/null +++ b/i18n/en.toml @@ -0,0 +1,24 @@ +# Translations for English +# https://gohugo.io/content-management/multilingual/#translation-of-strings + +# 404.html +# +[notFound] +other = "Oops, page not found…" + +[home] +other = "Home" + +[archives] +other = "Archives" + +# posts/single.html +# +[wordCount] +other = "{{ .WordCount }} Words" + +[newer] +other = "Newer" + +[older] +other = "Older" diff --git a/i18n/zh-hans.toml b/i18n/zh-hans.toml new file mode 100644 index 0000000..605cd6b --- /dev/null +++ b/i18n/zh-hans.toml @@ -0,0 +1,24 @@ +# Translations for Simplified Chinese - 简体中文 +# https://gohugo.io/content-management/multilingual/#translation-of-strings + +# 404.html +# +[notFound] +other = "糟糕,您要访问的页面不存在……" + +[home] +other = "主页" + +[archives] +other = "归档" + +# posts/single.html +# +[wordCount] +other = "{{ .WordCount }} 字" + +[newer] +other = "新" + +[older] +other = "旧" diff --git a/layouts/404.html b/layouts/404.html index 535fd1a..691ac08 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -5,10 +5,10 @@

diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 107b6d3..e8b37a8 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -4,7 +4,7 @@ {{ define "main" }} {{- with .Params.featuredImg }} -
+
{{- end }}