Add i18n support to the theme

This commit is contained in:
Danila Fedorin 2023-01-01 01:28:18 -08:00
parent f56465c5ec
commit 98ee4bd8f3
9 changed files with 73 additions and 25 deletions

View File

@ -261,7 +261,7 @@ figure {
margin: auto;
}
.draft-warning {
.warning {
@include bordered-block;
padding: 0.5rem;
background-color: #ffee99;

52
i18n/en.toml Normal file
View File

@ -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 <a href=\"mailto:danila.fedorin@gmail.com\">danila.fedorin@gmail.com</a>! I love receiving emails from readers, and I'm always happy to provide any additional clarification or assistance."
[note]
other = "note"

View File

@ -6,25 +6,21 @@
<a class="button" href="{{ $.Site.BaseURL }}/tags/{{ . | urlize }}">{{ . }}</a>
{{ end }}
</p>
<p>Posted on {{ .Date.Format "January 2, 2006" }}.</p>
<p>{{ i18n "postedOn" (.Date.Format "January 2, 2006") }}.</p>
</div>
<div class="post-content">
{{ if not (eq .TableOfContents "<nav id=\"TableOfContents\"></nav>") }}
<div class="table-of-contents">
<div class="wrapper">
<em>Table of Contents</em>
<em>{{ i18n "tableOfContents" }}</em>
{{ .TableOfContents }}
</div>
</div>
{{ end }}
{{ if .Draft }}
<div class="draft-warning">
<em>Warning!</em> 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!
</div>
{{ partial "warning.html" (i18n "postDraft") }}
{{ end }}
{{ .Content }}
@ -33,10 +29,7 @@
{{ define "after" }}
<hr class="container footer-divider">
<footer class="container">
<p>Liked this article? Have any questions or comments?
Please don't hesitate to reach out to me at <a href="mailto:danila.fedorin@gmail.com">
danila.fedorin@gmail.com</a>! I love receiving emails from readers, and I'm always happy
to provide any additional clarification or assistance.</p>
<p>{{ i18n "contactFooter" | safeHTML }}</p>
<!--
<p>I'm also currently looking for Computer Science internships for the summer
of 2021. Take a look at my <a href="/Resume-Danila-Fedorin.pdf">resume</a>,

View File

@ -1,7 +1,7 @@
{{ define "main" }}
{{ .Content }}
Recent posts:
{{ i18n "recentPosts" }}:
<ul class="post-list">
{{ range first 10 (where (where .Site.Pages.ByDate.Reverse "Section" "blog") ".Kind" "!=" "section") }}
{{ partial "post.html" . }}

View File

@ -1,15 +1,15 @@
<div class="container">
<h1>Daniel's Blog</h1>
<h1>{{ .Site.Title }}</h1>
</div>
<nav>
<div class="container">
<a href="{{ .Site.BaseURL }}">Home</a>
<a href="{{ relref . "about" }}">About</a>
<a href="{{ .Site.BaseURL }}">{{ i18n "home" }}</a>
<a href="{{ relref . "about" }}">{{ i18n "about" }}</a>
<a href="https://github.com/DanilaFe">GitHub</a>
<a href="{{ .Site.BaseURL }}/Resume-Danila-Fedorin.pdf">Resume</a>
<a href="{{ .Site.BaseURL }}/tags">Tags</a>
<a href="{{ .Site.BaseURL }}/favorites">Favorites</a>
<a href="{{ .Site.BaseURL }}/search">Search</a>
<a href="{{ relref . "blog" }}">All Posts</a>
<a href="{{ .Site.BaseURL }}/Resume-Danila-Fedorin.pdf">{{ i18n "resume" }}</a>
<a href="{{ .Site.BaseURL }}/tags">{{ i18n "tags" }}</a>
<a href="{{ .Site.BaseURL }}/favorites">{{ i18n "favorites" }}</a>
<a href="{{ .Site.BaseURL }}/search">{{ i18n "search" }}</a>
<a href="{{ relref . "blog" }}">{{ i18n "allPosts" }}</a>
</div>
</nav>

View File

@ -1,5 +1,5 @@
<li>
<a href="{{ .Permalink }}" class="post-title">{{ if .Params.favorite }}{{ partial "icon.html" "star" }}{{ end }} {{ .Title }}</a>
<p class="post-wordcount">{{ .WordCount }} words, about {{ .ReadingTime }} minutes to read.</p>
<p class="post-preview">{{ .Summary }} . . .</p>
<p class="post-wordcount">{{ i18n "nWords" .WordCount }}, {{ i18n "nMinutesToRead" .ReadingTime }}.</p>
<p class="post-preview">{{ .Summary }} {{ if .Truncated }}. . .{{ end }}</p>
</li>

View File

@ -0,0 +1,3 @@
<div class="warning">
<em>{{ i18n "warning" }}</em> {{ . }}
</div>

View File

@ -6,7 +6,7 @@
{{ else }}
<span class="sidenote-content sidenote-{{ .Get 0 }}">
{{ end }}
<span class="sidenote-delimiter">[note:</span>
<span class="sidenote-delimiter">[{{ i18n "note" }}:</span>
{{ .Inner }}
<span class="sidenote-delimiter">]</span>
</span>

View File

@ -1,5 +1,5 @@
{{ define "main" }}
<h2>Tagged "{{ .Title }}"</h2>
<h2>{{ i18n "tagged" .Title }}"</h2>
<ul class="post-list">
{{ range .Pages.ByDate.Reverse }}