From bac4e7fabed4319f91f9f6be0f92c9c4fdff9ec0a61275a339e0271d2ccaffa8 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Mon, 31 Jul 2023 00:00:00 +0000 Subject: Add multilingual support for reading time --- i18n/en.toml | 3 +++ layouts/partials/pageinfo.gmi | 2 +- layouts/partials/pageinfo.html | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 i18n/en.toml diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000..b602267 --- /dev/null +++ b/i18n/en.toml @@ -0,0 +1,3 @@ +[readingTime] + one = "1 minute read" + other = "{{ .Count }} minutes read" diff --git a/layouts/partials/pageinfo.gmi b/layouts/partials/pageinfo.gmi index 7ec43ff..e984eeb 100644 --- a/layouts/partials/pageinfo.gmi +++ b/layouts/partials/pageinfo.gmi @@ -1,2 +1,2 @@ {{ $dateFormat := .Site.Params.dateFormat | default "2 Jan 2006" -}} -{{ emojify ":calendar:" | safeHTML }} {{ .Page.PublishDate.Format $dateFormat | safeHTML }} | {{ emojify ":stopwatch:" | safeHTML }} {{ .Page.ReadingTime | safeHTML }} minute read{{ if .Page.Params.Tags }} | {{ emojify ":label:" | safeHTML }} {{ end }}{{ range $key, $val := .Page.Params.Tags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} \ No newline at end of file +{{ emojify ":calendar:" | safeHTML }} {{ .Page.PublishDate.Format $dateFormat | safeHTML }} | {{ emojify ":stopwatch:" | safeHTML }} {{ i18n "readingTime" .ReadingTime }}{{ if .Page.Params.Tags }} | {{ emojify ":label:" | safeHTML }} {{ end }}{{ range $key, $val := .Page.Params.Tags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} \ No newline at end of file diff --git a/layouts/partials/pageinfo.html b/layouts/partials/pageinfo.html index bba7c1c..4c8f419 100644 --- a/layouts/partials/pageinfo.html +++ b/layouts/partials/pageinfo.html @@ -1,2 +1,2 @@ {{ $dateFormat := .Site.Params.dateFormat | default "2 Jan 2006" -}} -{{ emojify ":calendar:" | safeHTML }} {{ .Page.PublishDate.Format $dateFormat | safeHTML }} | {{ emojify ":stopwatch:" | safeHTML }} {{ .Page.ReadingTime | safeHTML }} minute read{{ if .Page.Params.Tags }} | {{ emojify ":label:" | safeHTML }} {{ end }}{{ range $key, $val := .Page.Params.Tags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} +{{ emojify ":calendar:" | safeHTML }} {{ .Page.PublishDate.Format $dateFormat | safeHTML }} | {{ emojify ":stopwatch:" | safeHTML }} {{ i18n "readingTime" .ReadingTime | safeHTML }}{{ if .Page.Params.Tags }} | {{ emojify ":label:" | safeHTML }} {{ end }}{{ range $key, $val := .Page.Params.Tags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} -- cgit v1.2.3