summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-28 15:15:11 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-28 15:15:11 +0200
commit6b2b8e81e631a1fec44bdb94d5177cf5c56287c9 (patch)
tree994d425dd7ea4e4d57986e64fefd712de8011c03
parent512e94b28b243105e053c1090f56ac31846bc7cf (diff)
downloadgohugo-theme-ed-6b2b8e81e631a1fec44bdb94d5177cf5c56287c9.tar.gz
Added multilanguage support
-rw-r--r--CHANGELOG.md5
-rw-r--r--exampleSite/config.toml7
-rw-r--r--i18n/en.toml38
-rw-r--r--i18n/ru.toml38
-rw-r--r--layouts/404.html12
-rw-r--r--layouts/_default/baseof.html13
-rw-r--r--layouts/_default/home.manifest.webmanifest6
-rw-r--r--layouts/_default/list.json.json2
-rw-r--r--layouts/_default/teaser.html3
-rw-r--r--layouts/dramas/single.html2
-rw-r--r--layouts/narratives/single.html2
-rw-r--r--layouts/partials/footer.html2
-rw-r--r--layouts/partials/mini-toc.html3
-rw-r--r--layouts/partials/post-meta/date.html5
-rw-r--r--layouts/partials/post-toc-summary.html2
-rw-r--r--layouts/partials/sidebar-toc.html5
-rw-r--r--layouts/poems/single.html2
-rw-r--r--layouts/shortcodes/form-contact.html7
-rw-r--r--theme.toml6
19 files changed, 122 insertions, 38 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3573a4c..13c553d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/sergeyklay/gohugo-theme-ed/compare/v0.1.0...HEAD)
+### Added
+
+- Added multilanguage support
+- Added Russian translation
+
### Changed
- Amend documentation
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 3b82dc0..e2982d9 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -1,7 +1,9 @@
+# You may need to change this line for your real project.
baseURL = 'https://gohugo-theme-ed.netlify.app/'
languageCode = 'en-us'
defaultContentLanguage = 'en'
+
# Keep title short to prevent overflow.
# There’s no official guidance on this, but 40 characters for
# mobile and 60 for desktop is roughly the sweet spot.
@@ -9,8 +11,13 @@ defaultContentLanguage = 'en'
# NB: Final title of shareable pages will be this plus the
# title of the page. Eg. "Contacts - Ed."
title = 'Ed.'
+
+# You may need to change this line for your real project.
theme = ['github.com/sergeyklay/gohugo-theme-ed']
+
+# You may need to delete this line for your real project.
resourceDir = '../resources'
+
enableRobotsTXT = true
# When using ref or relref to resolve page links and a link cannot
diff --git a/i18n/en.toml b/i18n/en.toml
new file mode 100644
index 0000000..5792b4a
--- /dev/null
+++ b/i18n/en.toml
@@ -0,0 +1,38 @@
+[home]
+ other = 'Home'
+
+[top]
+ other = 'Return to Top'
+
+[more]
+ other = 'Read more...'
+
+[updated_at]
+ other = 'Updated at'
+
+[latest_publications]
+ other = 'Latest publications'
+
+[your_name]
+ other = 'Your name'
+
+[email_addres]
+ other = 'Email address'
+
+[message]
+ other = 'Message'
+
+[edited_by]
+ other = 'Edited by {{ . }}'
+
+[404_title]
+ other = 'Page not found'
+
+[404_description]
+ other = "Sorry, we've misplaced that URL or it's pointing to something that doesn't exist."
+
+[404_back]
+ other = 'Head back home to try finding it again'
+
+[by]
+ other = 'by {{ . }}'
diff --git a/i18n/ru.toml b/i18n/ru.toml
new file mode 100644
index 0000000..102c34d
--- /dev/null
+++ b/i18n/ru.toml
@@ -0,0 +1,38 @@
+[home]
+ other = 'На главную'
+
+[top]
+ other = 'Вернуться наверх'
+
+[more]
+ other = 'Далее...'
+
+[updated_at]
+ other = 'Обновлено'
+
+[latest_publications]
+ other = 'Последние публикации'
+
+[your_name]
+ other = 'Ваше имя'
+
+[email_addres]
+ other = 'Email'
+
+[message]
+ other = 'Сообщение'
+
+[edited_by]
+ other = 'Редактор {{ . }}'
+
+[404_title]
+ other = 'Страница не найдена'
+
+[404_description]
+ other = 'Извините, мы потеряли этот адрес или он указывает на что-то несуществующее.'
+
+[404_back]
+ other = 'Вернитесь на главную, чтобы попытаться найти страницу снова'
+
+[by]
+ other = '{{ . }}'
diff --git a/layouts/404.html b/layouts/404.html
index 5584276..1412779 100644
--- a/layouts/404.html
+++ b/layouts/404.html
@@ -3,17 +3,11 @@
<section class="introduction">
<div class="container">
<h1 class="accent">404</h1>
- <p><strong>Page not found</strong></p>
+ <p><strong>{{ i18n "404_title" }}</strong></p>
</div>
- <p>
- Sorry, we've misplaced that URL or it's pointing to something
- that doesn't exist.
- </p>
-
- <p>
- <a href="{{ "/" | relURL }}">Head back home to try finding it again</a>.
- </p>
+ <p>{{ i18n "404_description" }}</p>
+ <p><a href="{{ "/" | relURL }}">{{ i18n "404_back" }} </a>.</p>
</section>
<hr>
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 355f674..e05a918 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,21 +1,24 @@
<!DOCTYPE html>
<html lang="{{ site.LanguageCode | default site.Language.Lang }}" {{- with partialCached "func/GetLanguageDirection" "GetLanguageDirection" }} dir="{{ . }}" {{- end }} prefix="og: http://ogp.me/ns#">
- {{- partial "head.html" . -}}
+ {{ partial "head.html" . }}
<body class="theme-base-{{ site.Params.colorScheme }}">
- {{ if .Params.toc }}{{ partial "sidebar-toc.html" . }}{{ else }}{{ partial "sidebar.html" . }}{{ end }}
+ {{ if .Params.toc }}
+ {{ partial "sidebar-toc.html" . }}
+ {{ else }}
+ {{ partial "sidebar.html" . }}
+ {{ end }}
<div class="wrap">
<header class="masthead">
<div class="container">
<h3 class="masthead-title">
- {{/* TODO: Translate titlle */}}
- <a href="{{ site.Home.RelPermalink }}" title="Home">{{ site.Title }}</a>
+ <a href="{{ site.Home.RelPermalink }}" title="{{ i18n "home" }}">{{ site.Title }}</a>
<br><small>{{ site.Params.tagline }}</small>
</h3>
</div>
</header>
<main class="container content" id="main" data-type="{{ .Type }}">
- {{- block "main" . }}{{- end }}
+ {{ block "main" . }}{{ end }}
</main>
</div>
diff --git a/layouts/_default/home.manifest.webmanifest b/layouts/_default/home.manifest.webmanifest
index 0a84c55..c9437df 100644
--- a/layouts/_default/home.manifest.webmanifest
+++ b/layouts/_default/home.manifest.webmanifest
@@ -5,8 +5,8 @@
"name": {{ site.Title | htmlUnescape | jsonify }},
{{ with site.Params.tagline }}"short_name": {{ . | htmlUnescape | jsonify }},{{ end }}
{{ with site.Params.description }}"description": {{ . | htmlUnescape | jsonify }},{{ end }}
- {{ with site.LanguageCode }}"lang": {{ . | jsonify }},
- "dir": "ltr", {{/* TODO: Get dir from lang */}}{{ end }}
+ "lang": "{{ site.LanguageCode | default site.Language.Lang }}",{{ with partialCached "func/GetLanguageDirection" "GetLanguageDirection" }}
+ "dir": {{ . | jsonify }},{{ end }}
"start_url": "/index.html?homescreen=1",
"display": "fullscreen",
"theme_color": "#ffffff",
@@ -28,3 +28,5 @@
}{{ if ne . 512 }},{{ end }}{{- end }}
]
}
+
+
diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json
index 308bd96..30b6f80 100644
--- a/layouts/_default/list.json.json
+++ b/layouts/_default/list.json.json
@@ -16,7 +16,7 @@
{
"version": "https://jsonfeed.org/version/1.1",
- "title": {{ (printf "%s" (partial "title.html" .)) | htmlUnescape | jsonify }},{{/* TODO: Translate title */}}
+ "title": {{ (printf "%s" (partial "title.html" .)) | htmlUnescape | jsonify }},
"home_page_url": {{ printf "%s?utm_source=json_feed" site.BaseURL | absURL | jsonify }},
{{ with .OutputFormats.Get "JSON" }}"feed_url": {{ .Permalink | absURL | jsonify }},{{ end }}
{{ with site.Params.description}}"description": {{ site.Params.description | jsonify }},{{ end }}
diff --git a/layouts/_default/teaser.html b/layouts/_default/teaser.html
index 8e161c1..8edf8b4 100644
--- a/layouts/_default/teaser.html
+++ b/layouts/_default/teaser.html
@@ -12,8 +12,7 @@
{{- if site.Params.readmore }}
{{- if .Truncated }}
<footer>
- {{/* TODO: Translate me */}}
- <a href="{{ .RelPermalink }}" class="read-more">Read more...</a>
+ <a href="{{ .RelPermalink }}" class="read-more">{{ i18n "more" }}</a>
</footer>
{{- end }}
{{- end }}
diff --git a/layouts/dramas/single.html b/layouts/dramas/single.html
index dc31717..865a07b 100644
--- a/layouts/dramas/single.html
+++ b/layouts/dramas/single.html
@@ -1,7 +1,7 @@
{{ define "main" }}
<article class="drama">
<h1 class="text-title">{{ .Params.caption | default .Title }}</h1>
- <p class="byline">by {{ .Params.author }}</p>
+ {{ with .Params.author }}<p class="byline">{{ i18n "by" . }}</p>{{ end }}
{{ .Content }}
</article>
{{ end }}
diff --git a/layouts/narratives/single.html b/layouts/narratives/single.html
index 030af43..e3dc1b9 100644
--- a/layouts/narratives/single.html
+++ b/layouts/narratives/single.html
@@ -1,7 +1,7 @@
{{ define "main" }}
<article class="narrative">
<h1 class="text-title">{{ .Params.caption | default .Title }}</h1>
- <p class="byline">by {{ .Params.author }}</p>
+ {{ with .Params.author }}<p class="byline">{{ i18n "by" . }}</p>{{ end }}
{{ .Content }}
</article>
{{ end }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 7525a24..654a7a8 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -7,7 +7,7 @@
{{ end }}
{{ with .Params.editor }}
<p>
- Edited by {{ . }},
+ {{ i18n "edited_by" . }},
{{ if not $.Params.Lastmod.IsZero }}
{{ $.Params.Lastmod.Format "2006" }}
{{ else }}
diff --git a/layouts/partials/mini-toc.html b/layouts/partials/mini-toc.html
index 4d4d742..629169b 100644
--- a/layouts/partials/mini-toc.html
+++ b/layouts/partials/mini-toc.html
@@ -12,8 +12,7 @@
{{ $mxPosts := site.Params.recentPostsSize | default 5 }}
<div class="toc" role="navigation">
- {{/* TODO: Translate me */}}
- <h2>Latest Publications</h2>
+ <h2>{{ i18n "latest_publications" }}</h2>
<ul class="texts">
{{/* Range through the first $mxPosts items of the $section */}}
{{ range (first $mxPosts $section) }}
diff --git a/layouts/partials/post-meta/date.html b/layouts/partials/post-meta/date.html
index 29a86b8..92401e7 100644
--- a/layouts/partials/post-meta/date.html
+++ b/layouts/partials/post-meta/date.html
@@ -1,11 +1,10 @@
{{- if not .Date.IsZero }}
<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
- {{- .Date.Format (site.Params.dateformat | default "January 02, 2006") -}}
+ {{- .Date | time.Format (site.Params.dateformat | default "January 02, 2006") -}}
</time>
{{- if ne .Date .Lastmod }}
<time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">
- {{- /* TODO: Translate me */}}
- (Updated: {{ .Lastmod.Format (site.Params.dateformat | default "January 02, 2006") -}})
+ ({{ i18n "updated_at" }} {{ .Lastmod | time.Format (site.Params.dateformat | default "January 02, 2006") -}})
</time>
{{- end -}}
{{- end }}
diff --git a/layouts/partials/post-toc-summary.html b/layouts/partials/post-toc-summary.html
index d9a70c7..371a6f1 100644
--- a/layouts/partials/post-toc-summary.html
+++ b/layouts/partials/post-toc-summary.html
@@ -1,6 +1,6 @@
<span class="post-meta">
<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
- {{- .Date.Format (site.Params.dateFormatToc | default "2006.01.02") }}
+ {{- .Date | time.Format (site.Params.dateFormatToc | default "2006.01.02") }}
</time>
</span>
diff --git a/layouts/partials/sidebar-toc.html b/layouts/partials/sidebar-toc.html
index da7fd93..692643d 100644
--- a/layouts/partials/sidebar-toc.html
+++ b/layouts/partials/sidebar-toc.html
@@ -8,9 +8,8 @@
</div>
<nav class="sidebar-nav">
- {{/* TODO: Translate links */}}
- <a class="sidebar-nav-item" href="{{ site.Home.RelPermalink }}">Home</a>
- <a class="sidebar-nav-item" href="#" data-proofer-ignore>Return to Top</a>
+ <a class="sidebar-nav-item" href="{{ site.Home.RelPermalink }}">{{ i18n "home" }}</a>
+ <a class="sidebar-nav-item" href="#" data-proofer-ignore>{{ i18n "top" }}</a>
{{ range $item := .Params.toc }}
{{/* TODO: Add 'active' class for curent section */}}
diff --git a/layouts/poems/single.html b/layouts/poems/single.html
index c55eef8..d61a185 100644
--- a/layouts/poems/single.html
+++ b/layouts/poems/single.html
@@ -1,7 +1,7 @@
{{ define "main" }}
<article class="poem poetry">
<h1 class="text-title">{{ .Params.caption | default .Title }}</h1>
- <p class="byline">by {{ .Params.author }}</p>
+ {{ with .Params.author }}<p class="byline">{{ i18n "by" . }}</p>{{ end }}
{{ .Content }}
</article>
{{ end }}
diff --git a/layouts/shortcodes/form-contact.html b/layouts/shortcodes/form-contact.html
index 3be7777..1d216da 100644
--- a/layouts/shortcodes/form-contact.html
+++ b/layouts/shortcodes/form-contact.html
@@ -1,18 +1,17 @@
-{{- /* TODO: Translate me */ -}}
<div class="contact-form">
<form accept-charset="UTF-8" action="{{ site.Params.Contact.formAction | default site.BaseURL }}" method="POST" id="contact-form">
<div class="contact-form-item">
- <label for="name" class="contact-form-label">Your name</label>
+ <label for="name" class="contact-form-label">{{ i18n "your_name" }}</label>
<input type="text" id="name" name="name" class="contact-form-input form-input" placeholder="" required aria-labelledby="name">
</div>
<div class="contact-form-item">
- <label for="email" class="contact-form-label">Email addres</label>
+ <label for="email" class="contact-form-label">{{ i18n "email_addres" }}</label>
<input type="email" id="email" name="email" class="contact-form-input form-input" placeholder="" required aria-labelledby="email">
</div>
<div class="contact-form-item">
- <label for="message" class="contact-form-label">Message</label>
+ <label for="message" class="contact-form-label">{{ i18n "message" }}</label>
<textarea id="message" name="message" class="contact-form-textarea form-input" placeholder="" required aria-labelledby="message"></textarea>
</div>
diff --git a/theme.toml b/theme.toml
index 4e246d6..c661f3b 100644
--- a/theme.toml
+++ b/theme.toml
@@ -17,6 +17,7 @@ tags = [
"light",
"minimal",
"minimalist",
+ "multilingual",
"responsive",
"simple"
]
@@ -25,18 +26,19 @@ tags = [
features = [
"blog",
"clean",
+ "contact form",
"favicon",
"jsonfeed",
"minimal",
"minimalist",
"mobile",
+ "multilingual",
"opengraph",
"posts",
"responsive",
"rss",
"shortcodes",
- "simple",
- "contact form"
+ "simple"
]
min_version = "0.95.0"