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; margin: auto;
} }
.draft-warning { .warning {
@include bordered-block; @include bordered-block;
padding: 0.5rem; padding: 0.5rem;
background-color: #ffee99; 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> <a class="button" href="{{ $.Site.BaseURL }}/tags/{{ . | urlize }}">{{ . }}</a>
{{ end }} {{ end }}
</p> </p>
<p>Posted on {{ .Date.Format "January 2, 2006" }}.</p> <p>{{ i18n "postedOn" (.Date.Format "January 2, 2006") }}.</p>
</div> </div>
<div class="post-content"> <div class="post-content">
{{ if not (eq .TableOfContents "<nav id=\"TableOfContents\"></nav>") }} {{ if not (eq .TableOfContents "<nav id=\"TableOfContents\"></nav>") }}
<div class="table-of-contents"> <div class="table-of-contents">
<div class="wrapper"> <div class="wrapper">
<em>Table of Contents</em> <em>{{ i18n "tableOfContents" }}</em>
{{ .TableOfContents }} {{ .TableOfContents }}
</div> </div>
</div> </div>
{{ end }} {{ end }}
{{ if .Draft }} {{ if .Draft }}
<div class="draft-warning"> {{ partial "warning.html" (i18n "postDraft") }}
<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>
{{ end }} {{ end }}
{{ .Content }} {{ .Content }}
@ -33,10 +29,7 @@
{{ define "after" }} {{ define "after" }}
<hr class="container footer-divider"> <hr class="container footer-divider">
<footer class="container"> <footer class="container">
<p>Liked this article? Have any questions or comments? <p>{{ i18n "contactFooter" | safeHTML }}</p>
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>I'm also currently looking for Computer Science internships for the summer <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>, of 2021. Take a look at my <a href="/Resume-Danila-Fedorin.pdf">resume</a>,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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