add: basic i18n for list and single

This commit is contained in:
Guillaume Lodi 2022-02-04 17:48:46 +01:00
parent f6133c4eac
commit e7bda5f935
5 changed files with 30 additions and 14 deletions

View file

@ -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

15
i18n/en.yaml Normal file
View file

@ -0,0 +1,15 @@
# Learn how to use Date format (date, created, updated)
# -> https://gohugo.io/functions/dateformat/
posts:
title:
other: "Posts"
date:
other: "Jan, 2 2006"
post:
created:
other: "Jan, 2 2006"
updated:
other: "Updated Jan, 2 2006"

View file

@ -1,6 +1,6 @@
<li>
<a href="{{ .Permalink }}">
{{ .Title }}
<small><time>{{ .Date.Format "Jan 2, 2006" }}</time></small>
</a>
<a href="{{ .Permalink }}">
{{ .Title }}
<small><time>{{ .Date | time.Format (i18n "posts.date") }}</time></small>
</a>
</li>

View file

@ -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>

View file

@ -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" }}