An appeal to theme authors for micro.blog
Dear micro.blog theme authors, I kindly ask you:
Please avoid using {{ .Date.Format "Jan 2, 2006"
}} for dates
Instead, use the better format {{ time.Format "Jan 2, 2006" .Date
}} that supports international date translations.
This will allow non-English speakers to set defaultContentLanguage
and see dates in their own language.
It would be even better if you could take parameters from the config.json file to indicate the short and long date formats, to adapt them to the way they are written in other countries.
Let me give you a practical example..
I am Italian, and in our country we are used to read and write 10 January 2025
instead of January 10, 2025
. To adapt the date format to my specific needs, I could add these two parameters in the config.json
file like this:
{
"paginate": 20,
"defaultContentLanguage": "it",
"params": {
"dateFormatLong": "2 January 2006",
"dateFormatShort": "2 Jan 2006"
}
}
Then, you would just need to modify the files where the date is written; if a dateFormatLong
or dateFormatShort
parameter exists, use it. If not, default to a standard value. For example:
<div class="post-date-wrapper">
{{ $dateFormatLong := default "January 2, 2006" .Site.Params.dateFormatLong }}
<time class='dt-published' datetime='{{ .Date.Format "2006-01-02 15:04:05 -0700" }}'>
{{ time.Format $dateFormatLong .Date }}
</time>
</div>
Here are two example images taken from my site
In the first image, this modification is not applied, and the dates are displayed in the default format (i.e., in English):
In the second image, the modification is applied, and the dates appear in Italian (simply because I set "defaultContentLanguage": "it"
in the config.json file):
Finally, in the third example i set defaultContentLanguage
to fr
(french):