This commit is contained in:
Haris 2023-12-16 13:33:06 -08:00 committed by GitHub
commit 0e92a1e292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 27 deletions

View File

@ -38,7 +38,7 @@
- Social Icons (home-info and profile-mode)
- Social-Media Share buttons on posts.
- Menu location indicator.
- Multilingual support. (with language selector)
- Multilingual support (with improved language selector)
- Taxonomies
- Cover image for each post (with Responsive image support).
- Light/Dark theme (automatic theme switch a/c to browser theme and theme-switch button).

View File

@ -13,7 +13,7 @@
{{ .Description }}
</div>
{{- end }}
{{- if not (.Param "hideMeta") }}
{{- if and (.Param "showTranslationListInPosts") (not (.Param "hideMeta")) }}
<div class="post-meta">
{{- partial "translation_list.html" . -}}
</div>

View File

@ -22,7 +22,9 @@
{{- if not (.Param "hideMeta") }}
<div class="post-meta">
{{- partial "post_meta.html" . -}}
{{- if .Param "showTranslationListInPosts" }}
{{- partial "translation_list.html" . -}}
{{- end }}
{{- partial "edit_post.html" . -}}
{{- partial "post_canonical.html" . -}}
</div>

View File

@ -96,27 +96,42 @@
</button>
{{- end }}
{{- $lang := .Lang}}
{{- $separator := or $label_text (not site.Params.disableThemeToggle)}}
{{- with site.Home.AllTranslations }}
{{/* LANGUAGE SELECTOR */}}
{{ if .Site.IsMultiLingual }}
{{/* set vars with page data */}}
{{ $currentLang := .Lang }}
{{ $allTranslations := .Translations }}
{{ $separator := or $label_text (not site.Params.disableThemeToggle)}}
<ul class="lang-switch">
{{- if $separator }}<li>|</li>{{ end }}
{{- range . -}}
{{- if ne $lang .Lang }}
{{ if $separator }}<li>|</li>{{ end }}
{{ range $anySiteLang := .Site.Home.AllTranslations }}
{{/* code here can only access page-related data via vars set above */}}
{{ if ne $currentLang $anySiteLang.Lang }}
{{ $translationLink := .Permalink }}
{{ range $translation := $allTranslations }}
{{ if eq $anySiteLang.Lang $translation.Lang }}
{{ $translationLink = $translation.Permalink }}
{{ end }}
{{ end }}
<li>
<a href="{{- .Permalink -}}" title="{{ .Language.Params.languageAltTitle | default (.Language.LanguageName | emojify) | default (.Lang | title) }}"
aria-label="{{ .Language.LanguageName | default (.Lang | title) }}">
{{- if (and site.Params.displayFullLangName (.Language.LanguageName)) }}
{{- .Language.LanguageName | emojify -}}
{{- else }}
{{- .Lang | title -}}
{{- end -}}
<a href="{{ $translationLink }}"
title="{{ .Language.Params.languageAltTitle | default (.Language.LanguageName ) | default (.Lang | upper) }}"
aria-label="{{ .Language.LanguageName | default (.Lang | upper) }}">
{{ if site.Params.DisplayFullLangName }}
{{ .Language.LanguageName }}
{{ else }}
{{ .Lang | upper }}
{{ end }}
</a>
</li>
{{- end -}}
{{- end}}
{{ end }}
{{ end }}
</ul>
{{- end }}
{{ end }}
</div>
</div>
{{- $currentPage := . }}