Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/LukasJoswiak/etch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume <guillaume.lodi@gmail.com>2022-02-07 08:54:13 +0300
committerGitHub <noreply@github.com>2022-02-07 08:54:13 +0300
commit4791a2394906ad6269ee736ef2130a790332df12 (patch)
tree24bf0f532b24ebdcd979f4c1d99e406a35f24ac5
parentf6133c4eac182bdd560ed80c4c07495b043ed8fd (diff)
Add basic i18n for list and single (#30)
* add: basic i18n for list and single * add: apply suggestions * fix: indent using 4 tabs
-rw-r--r--README.md1
-rw-r--r--i18n/en.toml19
-rw-r--r--layouts/_default/li.html2
-rw-r--r--layouts/_default/single.html18
-rw-r--r--layouts/partials/posts.html2
5 files changed, 31 insertions, 11 deletions
diff --git a/README.md b/README.md
index 0a0b829..e46750b 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,7 @@ Etch is a simple, responsive theme for [Hugo](https://gohugo.io) with a focus on
* Syntax highlighting with customizable theme.
* Dark theme which automatically adjusts based on users' setting ([example](https://github.com/LukasJoswiak/etch/wiki/Dark-mode)).
* No external dependencies, no JavaScript, no web fonts.
+* Internationalization friendly: use default English translations or create your own
## Installation
diff --git a/i18n/en.toml b/i18n/en.toml
new file mode 100644
index 0000000..30f39ff
--- /dev/null
+++ b/i18n/en.toml
@@ -0,0 +1,19 @@
+# Learn how to use Date format (date, created, updated)
+# -> https://gohugo.io/functions/dateformat/
+
+[posts]
+
+[posts.title]
+other = "Posts"
+
+[posts.date]
+other = "Jan 2, 2006"
+
+
+[post]
+
+[post.created]
+other = "Jan 2, 2006"
+
+[post.updated]
+other = "Updated Jan 2, 2006" \ No newline at end of file
diff --git a/layouts/_default/li.html b/layouts/_default/li.html
index a273289..f418cb9 100644
--- a/layouts/_default/li.html
+++ b/layouts/_default/li.html
@@ -1,6 +1,6 @@
<li>
<a href="{{ .Permalink }}">
{{ .Title }}
- <small><time>{{ .Date.Format "Jan 2, 2006" }}</time></small>
+ <small><time>{{ .Date | time.Format (i18n "posts.date") }}</time></small>
</a>
</li>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index db7888c..e7602b7 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -2,15 +2,15 @@
<article>
<header id="post-header">
<h1>{{ .Title }}</h1>
- <div>
- {{- if isset .Params "date" -}}
- {{ if eq .Lastmod .Date }}
- <time>{{ .Date.Format "January 2, 2006" }}</time>
- {{ else }}
- Updated <time>{{ .Lastmod.Format "January 2, 2006" }}</time>
- {{ end }}
- {{- end -}}
- </div>
+ <div>
+ {{- if isset .Params "date" -}}
+ {{ if eq .Lastmod .Date }}
+ <time>{{ .Date | time.Format (i18n "post.created") }}</time>
+ {{ else }}
+ <time>{{ .Date | time.Format (i18n "post.updated") }}</time>
+ {{ end }}
+ {{- end -}}
+ </div>
</header>
{{- .Content -}}
</article>
diff --git a/layouts/partials/posts.html b/layouts/partials/posts.html
index 8ff3eb2..a741908 100644
--- a/layouts/partials/posts.html
+++ b/layouts/partials/posts.html
@@ -1,4 +1,4 @@
-<h3>Posts</h3>
+<h3>{{ i18n "posts.title" }}</h3>
<ul id="posts">
{{- range where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ .Render "li" }}