From a2117a0093a8354010ee54a9dd8e0557e6ab8d38 Mon Sep 17 00:00:00 2001
From: Danila Fedorin
Date: Sun, 1 Jan 2023 01:28:18 -0800
Subject: [PATCH] Add i18n support to the theme
---
assets/scss/style.scss | 2 +-
i18n/en.toml | 52 ++++++++++++++++++++++++++++++++
layouts/blog/single.html | 15 +++------
layouts/index.html | 2 +-
layouts/partials/header.html | 16 +++++-----
layouts/partials/post.html | 4 +--
layouts/shortcodes/sidenote.html | 2 +-
layouts/tags/list.html | 2 +-
8 files changed, 70 insertions(+), 25 deletions(-)
create mode 100644 i18n/en.toml
diff --git a/assets/scss/style.scss b/assets/scss/style.scss
index d5ade8a..e44c223 100755
--- a/assets/scss/style.scss
+++ b/assets/scss/style.scss
@@ -261,7 +261,7 @@ figure {
margin: auto;
}
-.draft-warning {
+.warning {
@include bordered-block;
padding: 0.5rem;
background-color: #ffee99;
diff --git a/i18n/en.toml b/i18n/en.toml
new file mode 100644
index 0000000..06de036
--- /dev/null
+++ b/i18n/en.toml
@@ -0,0 +1,52 @@
+[home]
+ other = "Home"
+
+[about]
+ other = "About"
+
+[resume]
+ other = "Resume"
+
+[tags]
+ other = "Tags"
+
+[favorites]
+ other = "Favorites"
+
+[search]
+ other = "Search"
+
+[allPosts]
+ other = "All Posts"
+
+[nWords]
+ one = "one word"
+ other = "{{ .Count }} words"
+
+[nMinutesToRead]
+ one = "about one minute to read"
+ other = "about {{ .Count }} minutes to read"
+
+[recentPosts]
+ other = "Recent posts"
+
+[tagged]
+ other = "Tagged \"{{ . }}\""
+
+[postedOn]
+ other = "Posted on {{ . }}"
+
+[tableOfContents]
+ other = "Table of Contents"
+
+[warning]
+ other = "Warning!"
+
+[postDraft]
+ other = "This post is a draft. At best, it may contain grammar mistakes; at worst, it can include significant errors and bugs. Please use your best judgement!"
+
+[contactFooter]
+ other = "Liked this article? Have any questions or comments? Please don't hesitate to reach out to me at danila.fedorin@gmail.com ! I love receiving emails from readers, and I'm always happy to provide any additional clarification or assistance."
+
+[note]
+ other = "note"
diff --git a/layouts/blog/single.html b/layouts/blog/single.html
index 3295155..0ec4e06 100644
--- a/layouts/blog/single.html
+++ b/layouts/blog/single.html
@@ -6,25 +6,21 @@
{{ . }}
{{ end }}
- Posted on {{ .Date.Format "January 2, 2006" }}.
+ {{ i18n "postedOn" (.Date.Format "January 2, 2006") }}.
{{ if not (eq .TableOfContents "
") }}
- Table of Contents
+ {{ i18n "tableOfContents" }}
{{ .TableOfContents }}
{{ end }}
{{ if .Draft }}
-
- Warning! This post is a draft. At best, it may contain grammar mistakes;
- at worst, it can include significant errors and bugs. Please
- use your best judgement!
-
+ {{ partial "warning.html" (i18n "postDraft") }}
{{ end }}
{{ .Content }}
@@ -33,10 +29,7 @@
{{ define "after" }}
- Liked this article? Have any questions or comments?
- Please don't hesitate to reach out to me at
- danila.fedorin@gmail.com ! I love receiving emails from readers, and I'm always happy
- to provide any additional clarification or assistance.
+ {{ i18n "contactFooter" | safeHTML }}