hugo-soresu

My fork of hugo-xmin

git clone git://git.shimmy1996.com/hugo-soresu.git
commit 668927f3087035227d5b851a89fcead49e8b144e
parent 4936ae52ebb8bf89666b968aa929d5c760b2dc59
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Sat, 23 Jun 2018 09:14:01 -0500

Improve parsing and translation of taxonomies.

Diffstat:
Mlayouts/_default/list.html | 2+-
Mlayouts/_default/single.html | 6+++---
Mlayouts/_default/terms.html | 4++--
Alayouts/partials/i18n_fallback.html | 6++++++
Dlayouts/partials/i18n_title.html | 6------
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
@@ -1,5 +1,5 @@
 {{ partial "header.html" . }}
-{{ partial "i18n_title.html" . }}
+<h1>{{ partial "i18n_fallback.html" .Title }}</h1>
 
 <main>{{ .Content }}</main>
 
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
@@ -5,11 +5,11 @@
 {{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
 {{ if (lt 0 .Params.date) }}<h2 class="date">{{ .Date.Format "2006-01-02" }}</h2>{{ end }}
 <p class="terms">
-{{ range $key, $name := .Site.Params.Taxonomy }}
+{{ range $key, $_ := .Site.Taxonomies }}
   {{ with ($.Param $key) }}
-    {{ $name }} |
+    {{ partial "i18n_fallback" $key }} |
     {{ range $term := . }}
-      <a href="{{ print "/" $key "/" $term | relLangURL}}">{{ i18n $term }}</a> |
+      <a href="{{ print "/" $key "/" $term | urlize | relLangURL}}">{{ partial "i18n_fallback" $term }}</a> |
     {{ end }}
     <br/>
   {{ end }}
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
@@ -1,11 +1,11 @@
 {{ partial "header.html" . }}
-{{ partial "i18n_title.html" . }}
+<h1>{{ partial "i18n_fallback.html" .Title }}</h1>
 
 <main>{{ .Content }}</main>
 
 <ul class="terms">
   {{ range $key, $value := .Data.Terms }}
-  <li><a href="{{ print "/" $.Data.Plural "/" $key | relLangURL }}">{{ i18n $key }}</a>({{ len $value }})</li>
+  <li><a href="{{ print "/" $.Data.Plural "/" $key | urlize | relLangURL }}">{{ partial "i18n_fallback" $key }}</a>({{ len $value }})</li>
 {{ end }}
 </ul>
 
diff --git a/layouts/partials/i18n_fallback.html b/layouts/partials/i18n_fallback.html
@@ -0,0 +1,6 @@
+{{ $translation := i18n (lower .) }}
+{{ if eq $translation "" }}
+  {{ if eq . (lower .)}} {{ . | humanize }} {{ else }} {{ . }} {{ end }}
+{{else}}
+  {{ $translation }}
+{{end}}
diff --git a/layouts/partials/i18n_title.html b/layouts/partials/i18n_title.html
@@ -1,6 +0,0 @@
-{{ $title := i18n (lower .Title) }}
-{{ if eq $title ""}}
-  <h1>{{ .Title }}</h1>
-{{ else }}
-  <h1>{{ $title }}</h1>
-{{ end }}