🌐 Add language switcher to header

pull/100/head
James Panther 2022-01-11 12:00:27 +11:00
parent fe90990e10
commit 9c8601102c
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
8 changed files with 23 additions and 47 deletions

View File

@ -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

View File

@ -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]

View File

@ -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/"

View File

@ -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."

View File

@ -1,6 +1,8 @@
<!DOCTYPE html>
<html
lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en{{ end }}"
lang="{{ with .Site.Language.Params.htmlCode | default (.Site.LanguageCode | default "en") }}
{{- . -}}
{{ end }}"
{{ if .Site.Params.darkMode | default false }}class="dark"{{ end }}
>
{{- partial "head.html" . -}}

View File

@ -1,6 +1,6 @@
<head>
<meta charset="utf-8" />
{{ with .Site.LanguageCode }}
{{ with .Site.Language.Params.htmlCode | default .Site.LanguageCode }}
<meta http-equiv="content-language" content="{{ . }}" />
{{ end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

View File

@ -6,7 +6,7 @@
{{ if .Site.Params.Logo -}}
{{ $logo := resources.Get .Site.Params.Logo }}
{{ if $logo }}
<a href="{{ "/" | relURL }}">
<a href="{{ "/" | relLangURL }}">
<img
src="{{ $logo.RelPermalink }}"
width="{{ div $logo.Width 2 }}"
@ -20,10 +20,11 @@
<a
class="hover:underline hover:decoration-primary-500 hover:decoration-2 hover:underline-offset-2"
rel="me"
href="{{ "/" | relURL }}"
href="{{ "/" | relLangURL }}"
>{{ .Site.Title | markdownify | emojify }}</a
>
{{- end }}
{{ partial "translations.html" . }}
</div>
{{/* Main menu */}}
{{ if .Site.Menus.main }}

View File

@ -0,0 +1,7 @@
{{ if .IsTranslated }}
<nav class="inline">
{{ range .AllTranslations }}
<a href="{{ .RelPermalink }}">{{ .Language.Params.displayName | emojify }}</a>
{{ end }}
</nav>
{{ end }}