From 9c8601102c5948906669a2ec30c1a679ed1aaffc Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Tue, 11 Jan 2022 12:00:27 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=90=20Add=20language=20switcher=20to?= =?UTF-8?q?=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++ .../config/_default/languages.en-au.toml | 6 ++- exampleSite/config/_default/params.toml | 2 +- i18n/en-au.yaml | 40 ------------------- layouts/_default/baseof.html | 4 +- layouts/partials/head.html | 2 +- layouts/partials/header.html | 5 ++- layouts/partials/translations.html | 7 ++++ 8 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 i18n/en-au.yaml create mode 100644 layouts/partials/translations.html diff --git a/CHANGELOG.md b/CHANGELOG.md index b164da64..fd4eb504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added + +- Multilingual support + ### Changed - Upgrade to Tailwind v3.0.12 diff --git a/exampleSite/config/_default/languages.en-au.toml b/exampleSite/config/_default/languages.en-au.toml index 5dfa40fb..98317260 100644 --- a/exampleSite/config/_default/languages.en-au.toml +++ b/exampleSite/config/_default/languages.en-au.toml @@ -1,8 +1,10 @@ -languageCode = "en-AU" +languageCode = "en-au" languageName = "English (Australia)" +displayName = ":flag-au:" +htmlCode = "en-AU" weight = 1 -title = "Congo :flag-au:" +title = "Congo" # copyright = "Copy, _right?_ :thinking_face:" [author] diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index ddbfebf9..163658ab 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -21,7 +21,7 @@ mainSections = ["samples"] showDate = true dateFormat = "2 January 2006" showAuthor = true - showBreadcrumbs = false + showBreadcrumbs = true showDraftLabel = true showEdit = true editURL = "https://github.com/jpanther/congo/tree/dev/exampleSite/content/" diff --git a/i18n/en-au.yaml b/i18n/en-au.yaml deleted file mode 100644 index 6cb5c3d5..00000000 --- a/i18n/en-au.yaml +++ /dev/null @@ -1,40 +0,0 @@ -article: - anchor_label: "Anchor" - draft: "Draft" - edit_title: "Edit content" - reading_time: - one: "{{ .Count }} min" - other: "{{ .Count }} mins" - reading_time_title: "Reading time" - word_count: - one: "{{ .Count }} word" - other: "{{ .Count }} words" - -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: - dark_appearance: "Switch to dark appearance" - light_appearance: "Switch to light appearance" - powered_by: "Powered by {{ .Hugo }} & {{ .Congo }}" - -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" - pinterest: "Pin on Pinterest" - reddit: "Submit to Reddit" - twitter: "Tweet on Twitter" - -shortcode: - recent_articles: "Recent" - icon_none: "Icon not found." diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index c3d077d5..46926391 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,6 +1,8 @@ {{- partial "head.html" . -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index c3ce9fd9..4e45ad92 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,6 +1,6 @@
- {{ with .Site.LanguageCode }} + {{ with .Site.Language.Params.htmlCode | default .Site.LanguageCode }} {{ end }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index cd1dfa13..e1c045bc 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -6,7 +6,7 @@ {{ if .Site.Params.Logo -}} {{ $logo := resources.Get .Site.Params.Logo }} {{ if $logo }} - + {{ .Site.Title | markdownify | emojify }} {{- end }} + {{ partial "translations.html" . }} {{/* Main menu */}} {{ if .Site.Menus.main }} diff --git a/layouts/partials/translations.html b/layouts/partials/translations.html new file mode 100644 index 00000000..001e38cd --- /dev/null +++ b/layouts/partials/translations.html @@ -0,0 +1,7 @@ +{{ if .IsTranslated }} + +{{ end }}