I'm trying to translate my Jekyll dates to French.
I followed the advice on this old reply on another StackOverflow question.
The idea is to create a custom plugin that:
- translates the names of months to French, and
- creates an html5-friendly date format for the <time>element.
Here's the code, copied from the other question and adapted from Italian: (french_dates.rb in my _plugins folder)
module Jekyll
module FrenchDates
    MONTHS = {"01" => "janvier", "02" => "février", "03" => "mars",
            "04" => "avril", "05" => "mai", "06" => "juin",
            "07" => "juillet", "08" => "août", "09" => "septembre",
            "10" => "octobre", "11" => "novembre", "12" => "décembre"}
    # http://man7.org/linux/man-pages/man3/strftime.3.html
    def frenchDate(date)
        day = time(date).strftime("%e") # leading zero is replaced by a space
        month = time(date).strftime("%m")
        year = time(date).strftime("%Y")
        day+' '+MONTHS[month]+' '+year
    end
    def html5date(date)
        day = time(date).strftime("%d")
        month = time(date).strftime("%m")
        year = time(date).strftime("%Y")
        year+'-'+month+'-'+day
    end
end
end
Liquid::Template.register_filter(Jekyll::FrenchDates)
And in Jekyll, call the plugin like this: (in my case in _layouts/blog.html)
<time datetime="{{ page.date | html5date }}">{{ page.date | frenchDate }}</time>
My problem is that when I try to implement this on my Jekyll site, I get the following error message:
Liquid Exception: Invalid Date: 'nil' is not a valid datetime. in /_layouts/blog.html
How can I make this plugin work?
