summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_partials/select-language.html32
-rw-r--r--layouts/baseof.html2
-rw-r--r--layouts/rss.xml2
3 files changed, 17 insertions, 19 deletions
diff --git a/layouts/_partials/select-language.html b/layouts/_partials/select-language.html
index 6efcc61..5cb4a25 100644
--- a/layouts/_partials/select-language.html
+++ b/layouts/_partials/select-language.html
@@ -1,32 +1,30 @@
{{- /*
Selection of available languages.
-Dynamically links to corresponding page/post if a translated version exists, otherwise to homepage of that language as fallback.
+Dynamically links to corresponding versions of a page/post in other languages if translations exists.
-Note: `$activeLang` and `$allTranslationsForPage` are technically unnecessary variables, their values could be called with `$.Lang` and `$.Translations` respectively.
-These variables - together with the explicit naming of `.` context variables in other cases - were chosen for better readability and understandability of the code.
+Note: `.Site.Language.Name` and `.Site.Language.Locale` are interchangable with Argo's default hugo.toml configuration of `locale = "en"`.
+Yet the differentiation is deliberately maintained here in case a user defines their locale to e.g. "en-US";
*/ -}}
-{{- if gt (len site.Languages) 1 }}
-{{- $activeLang := .Lang }}
-{{- $allTranslationsForPage := .Translations }}
+{{- $pageVersionsList := .Rotate "language" }}
+{{- if gt (len $pageVersionsList) 1 }}
<div class="language-select">
<ul class="language-select__language-list">
- {{- range site.Languages }}
- {{- $currLangSlice := . }}
- {{- if ne $currLangSlice.Lang $activeLang }}
- {{- $targetPage := index (where site.Home.Translations "Lang" $currLangSlice.Lang) 0 }}
- {{- $translatedPage := index (where $allTranslationsForPage "Lang" $currLangSlice.Lang) 0 }}
- {{- if $translatedPage }}{{- $targetPage = $translatedPage }}{{- end }}
+ {{- range $pageVersionsList }}
+ {{- $activeLang := $.Site.Language }}
+ {{- $currentLang := .Site.Language }}
+ {{- if ne $activeLang $currentLang }}
<li class="language-select__language-item">
<a
- href="{{ $targetPage.RelPermalink }}"
- hreflang="{{ $targetPage.Lang }}"
- aria-label="{{ $targetPage.LinkTitle }} ({{ or $targetPage.Language.LanguageName $targetPage.Lang }})"
+ href="{{ .RelPermalink }}"
+ hreflang="{{ $currentLang.Locale }}"
+ aria-label="{{ .LinkTitle }} ({{ or $currentLang.Label $currentLang.Name }})"
+ title="{{ or $currentLang.Label $currentLang.Name }}"
>
<img
- src="/flags/{{ $targetPage.Lang }}.svg"
+ src="/flags/{{ $currentLang.Name }}.svg"
class="icon icon-flag"
- alt="{{ $targetPage.LinkTitle }} ({{ or $targetPage.Language.LanguageName $targetPage.Lang }})"
+ alt="{{ .LinkTitle }} ({{ or $currentLang.Label $currentLang.Name }})"
aria-hidden="true"
/>
</a>
diff --git a/layouts/baseof.html b/layouts/baseof.html
index 99f09d9..a6a1439 100644
--- a/layouts/baseof.html
+++ b/layouts/baseof.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="{{ .Language.LanguageCode }}" dir="{{ .Language.LanguageDirection | default "ltr" }}">
+<html lang="{{ .Language.Locale }}" dir="{{ .Language.Direction | default "ltr" }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
diff --git a/layouts/rss.xml b/layouts/rss.xml
index 9f70eb5..ea4ddc0 100644
--- a/layouts/rss.xml
+++ b/layouts/rss.xml
@@ -37,7 +37,7 @@
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo</generator>
- <language>{{ site.Language.LanguageCode }}</language>
+ <language>{{ site.Language.Locale }}</language>
{{- with $authorName }}<managingEditor>{{ . }}</managingEditor>{{ end }}
{{- with $authorName }}<webMaster>{{ . }}</webMaster>{{ end }}
{{- with .Site.Copyright }}<copyright>{{ . }}</copyright>{{ end }}