From 6ebc886dda6afb89f6006fa5768286692250d970 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 2 Oct 2023 16:33:15 +0200 Subject: [PATCH] Add support for i18n --- hugo.yaml | 24 +++++++++++++++++++++-- i18n/de.toml | 12 ++++++++++++ i18n/en.toml | 15 ++++++++++++++- layouts/index.html | 4 ++-- layouts/partials/nav.html | 40 ++++++++++++++++++++++++++++++++------- layouts/shortcodes/t.html | 1 + 6 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 i18n/de.toml create mode 100644 layouts/shortcodes/t.html diff --git a/hugo.yaml b/hugo.yaml index bf635a8..2440ce4 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -1,7 +1,5 @@ baseURL: 'newpipe-ev.de' title: NewPipe e.V. -languageCode: en-us -DefaultContentLanguage: en enableEmoji: true enableGitInfo: true enableRobotsTXT: true @@ -10,6 +8,28 @@ paginate: 9 darkmode_js: - assets/js/darkmode.js enableInlineShortcodes: true +defaultContentLanguage: de +defaultContentLanguageInSubdir: true +languages: + de: + contentDir: content + disabled: false + languageCode: de-DE + languageDirection: ltr + languageName: Deutsch + params: + subtitle: Referenz, Tutorials und Erklärungen + weight: 1 + en: + contentDir: content + disabled: false + languageCode: en-US + languageDirection: ltr + languageName: English + params: + subtitle: Reference, Tutorials, and Explanations + weight: 2 + markup: goldmark: diff --git a/i18n/de.toml b/i18n/de.toml new file mode 100644 index 0000000..2fd3d17 --- /dev/null +++ b/i18n/de.toml @@ -0,0 +1,12 @@ +prose = "Prosa" +about = "Über" +categories = "Kategorien" +dropdown = "Dropdown" +contact = "Kontakt" +appearance = "Aussehen" +comments = "Kommentare" +analytics = "Analytik" +basicInfo = "Dies sind die Grundinformationen über NewPipe e.V." + +moto = "Supporting privacy and open source software" +index_description = "NewPipe e.V. ist eine gemeinnützige Organisation, die sich für die Förderung von Datenschutz und Open-Source-Software einsetzt. Wir sind die Organisation hinter NewPipe, einer freien Medien-App für Android." diff --git a/i18n/en.toml b/i18n/en.toml index db453ed..ef90c2f 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -1,2 +1,15 @@ +prose = "Prose" +about = "About" +catergories = "Categories" +dropdown = "Dropdown" +contact = "Contact" +appearance = "Appearance" +comments = "Comments" +analytics = "Analytics" +basicInfo = "This is basic information about NewPipe e.V." + +moto = "Supporting privacy and open source software" +index_description = "NewPipe e.V. is a non-profit organization that aims to empower users to take back control of their data and to protect their privacy when using Android devices." + [wordCount] -other = "{{ .WordCount }} words" \ No newline at end of file +other = "{{ .WordCount }} words" diff --git a/layouts/index.html b/layouts/index.html index a7b7042..6138483 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -8,10 +8,10 @@ {{ .Site.Title }}

- {{ .Site.Params.Moto }} + {{ T "moto" }}

- {{ .Site.Params.Description}} + {{ T "index_description" }}

diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index a0392af..3bc19e9 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -7,7 +7,7 @@ class="transition-opacity h-9 w-9 group-hover:opacity-50 group-focus:opacity-70" alt="{{ .Site.Title }} Logo" />
+ class="mt-1 ml-3 text-xl font-black tracking-tight text-gray-100 transition-colors group-hover:text-gray-400/60"> {{ .Site.Title }}
@@ -117,7 +118,7 @@ {{ else }} - {{ .Name }} + {{ or (T .Identifier) .Name | safeHTML }} {{ end }} {{ end }} @@ -136,6 +137,31 @@ {{ end }} +
+ +
+
+ {{$currentUrl := trim .Page.RelPermalink "/"}} + {{ range (.Site.Languages) }} + {{- .LanguageName -}} + + {{ end }} +
+
+
\ No newline at end of file diff --git a/layouts/shortcodes/t.html b/layouts/shortcodes/t.html new file mode 100644 index 0000000..0ee67f7 --- /dev/null +++ b/layouts/shortcodes/t.html @@ -0,0 +1 @@ +{{- $text := .Get 0 -}}{{- T $text -}} \ No newline at end of file