Add i18n support

pull/2/head
James Panther 2021-08-17 16:48:08 +10:00
parent 18ed642ae4
commit 64dd424b80
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
18 changed files with 66 additions and 22 deletions

View File

@ -9,13 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added
- i18n support
### Changed ### Changed
- Consolidated author configuration parameters into `config.toml` - Consolidated author configuration parameters into `config.toml`
### Fixed ### Fixed
- Fixes URLs being incorrect in some cases when the site is deployed in a subfolder - URLs being incorrect in some cases when the site is deployed in a subfolder
## [1.0.0] - 2020-08-16 ## [1.0.0] - 2020-08-16

View File

@ -6,6 +6,7 @@ theme = "congo"
# baseURL = "https://your_domain.com/" # baseURL = "https://your_domain.com/"
languageCode = "en" languageCode = "en"
defaultContentLanguage = "en"
title = "Congo" title = "Congo"
# copyright = "Copy, _right?_ :thinking_face:" # copyright = "Copy, _right?_ :thinking_face:"

View File

@ -1,27 +1,27 @@
{ {
"email": { "email": {
"icon": "email", "icon": "email",
"title": "Send via email", "title": "sharing.email",
"url": "mailto:?body=%s&subject=%s" "url": "mailto:?body=%s&subject=%s"
}, },
"facebook": { "facebook": {
"icon": "facebook", "icon": "facebook",
"title": "Share on Facebook", "title": "sharing.facebook",
"url": "https://www.facebook.com/sharer/sharer.php?u=%s&quote=%s" "url": "https://www.facebook.com/sharer/sharer.php?u=%s&quote=%s"
}, },
"linkedin": { "linkedin": {
"icon": "linkedin", "icon": "linkedin",
"title": "Share on LinkedIn", "title": "sharing.linkedin",
"url": "https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s" "url": "https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s"
}, },
"reddit": { "reddit": {
"icon": "reddit", "icon": "reddit",
"title": "Submit to Reddit", "title": "sharing.reddit",
"url": "https://reddit.com/submit/?url=%s&resubmit=true&title=%s" "url": "https://reddit.com/submit/?url=%s&resubmit=true&title=%s"
}, },
"twitter": { "twitter": {
"icon": "twitter", "icon": "twitter",
"title": "Tweet on Twitter", "title": "sharing.twitter",
"url": "https://twitter.com/intent/tweet/?url=%s&text=%s" "url": "https://twitter.com/intent/tweet/?url=%s&text=%s"
} }
} }

View File

@ -10,6 +10,7 @@
baseURL = "https://jpanther.github.io/Congo/" baseURL = "https://jpanther.github.io/Congo/"
theme = "Congo" theme = "Congo"
languageCode = "en-AU" languageCode = "en-AU"
defaultContentLanguage = "en"
title = "Congo" title = "Congo"
enableEmoji = true enableEmoji = true
relativeURLs = true relativeURLs = true

View File

@ -34,7 +34,8 @@ Note that the variable names provided in this table use dot notation to simplify
| --- | --- | --- | --- | | --- | --- | --- | --- |
|`theme`|string|`"congo"`|This must be set to `"congo"` for the theme to function.| |`theme`|string|`"congo"`|This must be set to `"congo"` for the theme to function.|
|`baseURL`|string|_Not set_|The URL to the root of the website.| |`baseURL`|string|_Not set_|The URL to the root of the website.|
|`languageCode`|string|`"en"`|The language of the website. It can be a top-level language (ie. `"en"`) or a sub-variant (ie. `"en-AU"`)." |`languageCode`|string|`"en"`|The language of the website for site metadata purposes. It can be a top-level language (ie. `"en"`) or a sub-variant (ie. `"en-AU"`)."|
|`defaultContentLanguage`|string|`"en"`|This value determines the language of theme components."|
|`title`|string|`"Congo"`|The title of the website. This will be displayed in the site header and footer.| |`title`|string|`"Congo"`|The title of the website. This will be displayed in the site header and footer.|
|`copyright`|string|_Not set_|A Markdown string containing the copyright message to be displayed in the site footer. If none is provided, Congo will automatically generate a copyright string using the site `title`. |`copyright`|string|_Not set_|A Markdown string containing the copyright message to be displayed in the site footer. If none is provided, Congo will automatically generate a copyright string using the site `title`.
|`enableEmoji`|boolean|`true`|Whether emoji strings in content should be converted to emoji symbols.| |`enableEmoji`|boolean|`true`|Whether emoji strings in content should be converted to emoji symbols.|

35
i18n/en.yaml 100644
View File

@ -0,0 +1,35 @@
article:
anchor_label: "Anchor"
draft: "Draft"
reading_time:
one: "{{ .Count }} min"
other: "{{ .Count }} mins"
reading_time_title: "Reading time"
author:
byline_title: "Author"
error:
404_title: "Page Not Found :confused:"
404_error: "Error 404"
404_description: "It seems that the page you've requested does not exist."
footer:
powered_by: "Powered by"
homepage:
recent: "Recent"
list:
externalurl_title: "Link to external site"
no_articles: "There's no articles to list here yet."
sharing:
email: "Send via email"
facebook: "Share on Facebook"
linkedin: "Share on LinkedIn"
reddit: "Submit to Reddit"
twitter: "Tweet on Twitter"
shortcode:
no_icon: "Icon not found."

View File

@ -1,7 +1,7 @@
{{ define "main" }} {{ define "main" }}
<h1 class="mb-3 text-4xl font-extrabold">Page Not Found 🤷‍♂️</h1> <h1 class="mb-3 text-4xl font-extrabold">{{ i18n "error.404_title" | emojify }}</h1>
<p class="mt-8 mb-12 text-gray-400 dark:text-gray-500">Error 404</p> <p class="mt-8 mb-12 text-gray-400 dark:text-gray-500">{{ i18n "error.404_error" | emojify }}</p>
<div class="prose dark:prose-light"> <div class="prose dark:prose-light">
<p>It seems that the page you've requested does not exist.</p> <p>{{ i18n "error.404_description" | emojify }}</p>
</div> </div>
{{ end }} {{ end }}

View File

@ -1 +1 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} {{ if .Page.Params.showHeadingAnchors | default (.Page.Site.Params.article.showHeadingAnchors | default true) }}<a class="heading-anchor" href="#{{ .Anchor | safeURL }}" aria-label="Anchor">#</a>{{ end }}</h{{ .Level }}> <h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} {{ if .Page.Params.showHeadingAnchors | default (.Page.Site.Params.article.showHeadingAnchors | default true) }}<a class="heading-anchor" href="#{{ .Anchor | safeURL }}" aria-label="{{ i18n "article.anchor_label" }}">#</a>{{ end }}</h{{ .Level }}>

View File

@ -16,7 +16,7 @@
{{ else }} {{ else }}
<section class="mt-10 prose dark:prose-light"> <section class="mt-10 prose dark:prose-light">
<p class="py-8 border-t"> <p class="py-8 border-t">
<em>There's no articles to list here yet.</em> <em>{{ i18n "list.no_articles" | emojify }}</em>
</p> </p>
</section> </section>
{{ end }} {{ end }}

View File

@ -8,7 +8,7 @@
<span <span
class="ml-2 px-1 py-[2px] text-xs font-normal border rounded-md text-primary-700 dark:text-primary-400 border-primary-400 dark:border-primary-600 inline-block align-middle mb-1" class="ml-2 px-1 py-[2px] text-xs font-normal border rounded-md text-primary-700 dark:text-primary-400 border-primary-400 dark:border-primary-600 inline-block align-middle mb-1"
> >
Draft {{ i18n "article.draft" | emojify }}
</span> </span>
{{ end }} {{ end }}
</div> </div>

View File

@ -7,7 +7,7 @@
{{ end }} {{ end }}
{{ if .Site.Params.homepage.showList | default false }} {{ if .Site.Params.homepage.showList | default false }}
<section> <section>
<h2 class="text-2xl font-extrabold">Recent</h2> <h2 class="text-2xl font-extrabold">{{ i18n "homepage.recent" | emojify }}</h2>
{{ range first 5 (.Paginate (where .Site.RegularPages "Type" "in" .Site.Params.homepage.listSections)).Pages }} {{ range first 5 (.Paginate (where .Site.RegularPages "Type" "in" .Site.Params.homepage.listSections)).Pages }}
{{ partial "article-link.html" . }} {{ partial "article-link.html" . }}
{{ end }} {{ end }}

View File

@ -7,7 +7,7 @@
<span <span
class="text-sm cursor-default" class="text-sm cursor-default"
style="vertical-align: super;" style="vertical-align: super;"
title="Link to external site" title="{{ i18n "list.externalurl_title" }}"
>&#8599;</span >&#8599;</span
> >
{{ else }} {{ else }}

View File

@ -11,8 +11,7 @@
<span class="px-1">&middot;</span> <span class="px-1">&middot;</span>
{{ end }} {{ end }}
{{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0) }} {{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0) }}
<span title="Reading time"> <span title="{{ i18n "article.reading_time_title" }}">
{{ .ReadingTime }} {{ i18n "article.reading_time" .ReadingTime | emojify }}
min{{ if gt .ReadingTime 1 }}s{{ end }}
</span> </span>
{{ end }} {{ end }}

View File

@ -5,6 +5,9 @@
{{ end }} {{ end }}
<div> <div>
{{ with .Site.Author.name }} {{ with .Site.Author.name }}
<div class="text-[0.6rem] leading-3 text-gray-400 dark:text-gray-500 uppercase">
{{ i18n "author.byline_title" | emojify }}
</div>
<div class="font-semibold leading-6 text-gray-800 dark:text-gray-300"> <div class="font-semibold leading-6 text-gray-800 dark:text-gray-300">
{{ . }} {{ . }}
</div> </div>

View File

@ -12,7 +12,7 @@
{{/* Theme attribution */}} {{/* Theme attribution */}}
{{ if .Site.Params.attribution | default true }} {{ if .Site.Params.attribution | default true }}
<p class="text-xs text-gray-300 dark:text-gray-600"> <p class="text-xs text-gray-300 dark:text-gray-600">
Powered by {{ i18n "footer.powered_by" }}
<a class="hover:underline" href="https://gohugo.io/" target="_blank">Hugo</a> <a class="hover:underline" href="https://gohugo.io/" target="_blank">Hugo</a>
&amp; &amp;
<a class="hover:underline" href="https://git.io/hugo-congo" target="_blank">Congo</a> <a class="hover:underline" href="https://git.io/hugo-congo" target="_blank">Congo</a>

View File

@ -6,7 +6,7 @@
<a <a
class="bg-gray-300 text-gray-700 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-primary-400 dark:hover:text-gray-800 m-1 hover:bg-primary-500 hover:text-white rounded min-w-[2.4rem] inline-block text-center p-1" class="bg-gray-300 text-gray-700 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-primary-400 dark:hover:text-gray-800 m-1 hover:bg-primary-500 hover:text-white rounded min-w-[2.4rem] inline-block text-center p-1"
href="{{ printf .url $.Permalink $.Title }}" href="{{ printf .url $.Permalink $.Title }}"
title="{{ .title }}" title="{{ i18n .title }}"
>{{ partial "icon.html" .icon }}</a >{{ partial "icon.html" .icon }}</a
> >
{{ end }} {{ end }}

View File

@ -3,6 +3,6 @@
{{ if $icon }} {{ if $icon }}
{{ $icon.Content | safeHTML }} {{ $icon.Content | safeHTML }}
{{ else }} {{ else }}
<em>Icon not found.</em> <em>{{ i18n "shortcode.no_icon" }}</em>
{{ end }} {{ end }}
</span> </span>

File diff suppressed because one or more lines are too long