Browse Source

Add multilingual month support

At the time of this writing, Go does not yet have support for
internationalized locales for dates, if you create a month.yaml in your data/
folder with a content like shown below. It will work.

1: "janvier"
2: "février"
3: "mars"
4: "avril"
5: "mai"
6: "juin"
7: "juillet"
8: "août"
9: "septembre"
10: "octobre"
11: "novembre"
12: "décembre"
pull/3/head
Benedikt Tuchen 4 years ago
parent
commit
58e4c3224e
5 changed files with 40 additions and 3 deletions
  1. +25
    -0
      README.md
  2. +12
    -0
      exampleSite/data/month.yaml
  3. +1
    -1
      layouts/_default/list.html
  4. +1
    -1
      layouts/_default/single.html
  5. +1
    -1
      layouts/index.html

+ 25
- 0
README.md View File

@@ -12,6 +12,7 @@ Crisp, minimal personal website and blog theme Hugo. Forked from [Ezhil](https:/
* Disqus comments
* RSS feeds
* Custom CSS/JS
* Multilingual months support

## Installation

@@ -39,6 +40,30 @@ type: "page"
This is some static page where you can write about yourself.
```

## Language Settings for the month

Due to the currently unavailable feature for multilingual dates in ``.Date`` from
Go. It is possible to create a ``month.yaml`` in the data folder of your
Hugo site root directoy. There is also an example file in
``exampleSite/data/``.

```sh
cat > month.yaml << EOF
1: "Jan"
2: "Feb"
3: "Mar"
4: "Apr"
5: "May"
6: "Jun"
7: "Jul"
8: "Aug"
9: "Sep"
10: "Oct"
11: "Nov"
12: "Dec"
EOF
```

## Credits

* [Ezhil theme](https://github.com/vividvilla/ezhil) from which Ink was forked

+ 12
- 0
exampleSite/data/month.yaml View File

@@ -0,0 +1,12 @@
1: "Jan"
2: "Feb"
3: "Mar"
4: "Apr"
5: "May"
6: "Jun"
7: "Jul"
8: "Aug"
9: "Sep"
10: "Oct"
11: "Nov"
12: "Dec"

+ 1
- 1
layouts/_default/list.html View File

@@ -21,7 +21,7 @@
<div class="meta">
<div class="date">
<span class="day">{{ dateFormat "02" .Date }}</span>
<span class="rest">{{ dateFormat "Jan 2006" .Date }}</span>
<span class="rest">{{ if $.Site.Data.month }}{{ index $.Site.Data.month (printf "%d" .Date.Month) }} {{ .Date.Year }}{{ else }}{{ dateFormat "Jan 2006" .Date }}{{ end }}</span>
</div>
</div>
<div class="matter">

+ 1
- 1
layouts/_default/single.html View File

@@ -11,7 +11,7 @@
<div class="meta">
<div class="date">
<span class="day">{{ dateFormat "02" .Date }}</span>
<span class="rest">{{ dateFormat "Jan 2006" .Date }}</span>
<span class="rest">{{ if $.Site.Data.month }}{{ index $.Site.Data.month (printf "%d" .Date.Month) }} {{ .Date.Year }}{{ else }}{{ dateFormat "Jan 2006" .Date }}{{ end }}</span>
</div>
</div>
{{ end }}

+ 1
- 1
layouts/index.html View File

@@ -15,7 +15,7 @@
<div class="meta">
<div class="date">
<span class="day">{{ dateFormat "02" .Date }}</span>
<span class="rest">{{ dateFormat "Jan 2006" .Date }}</span>
<span class="rest">{{ if $.Site.Data.month }}{{ index $.Site.Data.month (printf "%d" .Date.Month) }} {{ .Date.Year }}{{ else }}{{ dateFormat "Jan 2006" .Date }}{{ end }}</span>
</div>
</div>
<div class="matter">

Loading…
Cancel
Save