From d7a2f609f464cc5ec29066284ea3611455382efd Mon Sep 17 00:00:00 2001 From: Timo Montalto Date: Mon, 24 Mar 2025 11:38:32 +0100 Subject: [PATCH] Added second language and some translations --- assets/css/dark.css | 14 ++++++++++++++ assets/css/main.css | 21 +++++++++++++++++++++ i18n/de.toml | 3 +++ i18n/en.toml | 18 ++++++++++++++++++ layouts/_default/single.html | 7 +++++++ layouts/partials/footer.html | 3 --- layouts/partials/head.html | 8 +++++++- 7 files changed, 70 insertions(+), 4 deletions(-) diff --git a/assets/css/dark.css b/assets/css/dark.css index 401dfc2..4a8a5bb 100644 --- a/assets/css/dark.css +++ b/assets/css/dark.css @@ -195,6 +195,20 @@ a:hover { border-color: #ffd700; } +.translations-block { + background-color: var(--darkMaincolor); + color: #000; +} + +.translations-block a { + color: #000; + border-bottom: 2px solid #000; +} + +.translations-block a:hover { + background-color: #000; + color: var(--darkMaincolor); +} .pagination li.active a { background-color: var(--darkMaincolor); diff --git a/assets/css/main.css b/assets/css/main.css index 3f00178..8436a84 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -434,4 +434,25 @@ table td{ .pagination li.disabled a:hover { background: transparent; +} + +.translations-block { + text-align: center; + margin: 20px 0; + padding: 10px; + background-color: var(--callouctcolor); + color: #fff; + border-radius: 5px; +} + +.translations-block a { + color: #fff; + text-decoration: none; + margin: 0 10px; + border-bottom: 2px solid #fff; +} + +.translations-block a:hover { + background-color: #fff; + color: var(--callouctcolor); } \ No newline at end of file diff --git a/i18n/de.toml b/i18n/de.toml index d214790..a3c3510 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -1,3 +1,6 @@ +[translatedVersion] +other = "This post is also available in English" + [more] other = "Mehr" diff --git a/i18n/en.toml b/i18n/en.toml index 4e5638d..9729778 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -1,3 +1,6 @@ +[translatedVersion] +other = "Dieser Beitrag ist auch auf Deutsch verfügbar" + [more] other = "More" @@ -10,6 +13,21 @@ other = "Recent {{.Title }}" [readMore] other = "read more" +[next] +other = "Next" + +[back] +other = "Back" + +[publishedOn] +other = "Published on" + +[pageNotFound] +other = "Nothing found here" + +[EntriesTagged] +other = "All tagged" + [by] other = "By" diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 5c5ada9..73b5593 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -12,6 +12,13 @@

{{ .Title }}

{{ i18n "publishedOn" }} {{ dateFormat ":date_medium" .Date }}{{ if .Draft }} DRAFT {{ end }}
+ {{ if .IsTranslated }} +
+ {{ range .Translations }} + {{ i18n "translatedVersion" }} + {{ end }} +
+ {{ end }}
{{ if isset .Params "tldr" }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 11fb999..8bdf558 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -16,6 +16,3 @@ {{ end }}
-{{ if not hugo.IsServer }} -{{ template "_internal/google_analytics.html" . }} -{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 08210c2..ec952a8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -17,8 +17,14 @@ {{ .Name }} {{ end }} {{ if eq .Site.Params.mode "toggle" -}} - | {{template "feathericon" (dict "UseCDN" .Site.Params.useCDN "Icon" "sun") }} + | {{template "feathericon" (dict "UseCDN" .Site.Params.useCDN "Icon" "sun") }} {{ end }} + + {{ if eq .Site.Language.Lang "de" -}} + | EN + {{ else -}} + | DE + {{ end }}