Closed Weishaupt closed 4 years ago
Hi, abbreviated month names in _layouts/home.html
and _layouts/post.html
uses:
{{ page.date | date: "%b %-d, %Y" }}
As %b
is used for Ruby's strftime
. So if you want to customize this, I think you should use a case-when statement like this gist.
{% assign m = page.date | date: "%-m" %}
{% capture month_abbrev_de %}
{% case m %}
{% when '1' %}Jan
{% when '2' %}Feb
{% when '3' %}März
{% when '4' %}Apr
{% when '5' %}Mai
{% when '6' %}Juni
{% when '7' %}Juli
{% when '8' %}Aug
{% when '9' %}Sept
{% when '10' %}Okt
{% when '11' %}Nov
{% when '12' %}Dez
{% endcase %}
{% endcapture %}
{{ month_abbrev_de }} {{ page.date | date: "%-d, %Y" }}
So the above code can replace {{ page.date | date: "%b %-d, %Y" }}
.
I think we can separate _includes/date.html
for ease of this kind of customization, since then you only have to write your own _includes/date.html
, instead of bothering with _config.yml
or overriding the whole layouts. How do you think?
As far as date formatting is concerned, there is a similar example on this page for the formatting.
I'd propose a _data/translations.yml
file where translatable strings are kept. In this case, we'd only have Jan
-Dec
and Read on
. The default site.language
then specifies, what language should be displayed.
When it comes to other languages, there might be other date formats preferred to the Month, Day, Year scheme. (In German the default would be Day, Month, Year.)
Maybe have a look at how the academic theme handles this.
I'd like to display my page in German. The items in the theme that need translation as far as I discovered are:
Read on
button onindex.html
index.html
and thepost
-layout.I'd suggest to enable translation by providing a yaml file where these values can be entered. If none are present, English is selected as default.