html - Jekyll archive link in another language than english -


i have code generate archive links jekyll

<div class="col-lg-4">     <h3>archives</h3>     <ul>         {% post in site.posts %}           {% assign thisyear = post.date | date: "%b %y" %}           {% assign prevyear = post.previous.date | date: "%b %y" %}           {% assign counter = counter | plus: 1 %}           {% if thisyear != prevyear %}             <li><a href="/archive/#{{ post.date | date:"%b %y" | }}">{{ thisyear }} ({{ counter }})</a></li>             {% assign counter = 0 %}           {% endif %}         {% endfor %}     </ul> </div> 

as can see render "may 2015 (3)". i'm trying achieve "mai 2015 (3)".

here how it's done simpler loop :

<div class="col-lg-4">     <h3>derniers articles</h3>     <ul class="posts">         {% post in site.posts limit:10 %}            <li>                <span>                {{ post.date | date: '%d' }}                {% assign m = post.date | date: "%-m" %}                     {% case m %}                       {% when '1' %}janvier                       {% when '2' %}février                       {% when '3' %}mars                       {% when '4' %}avril                       {% when '5' %}mai                       {% when '6' %}juin                       {% when '7' %}juillet                       {% when '8' %}août                       {% when '9' %}septembre                       {% when '10' %}octobre                       {% when '11' %}novembre                       {% when '12' %}décembre                     {% endcase %}                 {{ post.date | date: '%y' }}                 </span> &raquo;                <a href="{{ base_path }}{{ post.url }}">                {{ post.title }}</a>            </li>         {% endfor %}     </ul> </div> 

this code render "15 janvier 2015" instance instead of "15 january 2015".

up did not manage merge 2 loops create want achieve. idea ?

edit made progress code : there big problem, render 1 month instead of months. renders

mai 2015 (4) 

instead of

mai 2015 (1) juin 2015 (1) juillet 2015 (2) 

 

   <ul>         {% post in site.posts %}           {% assign thisyear = post.date | date: "%y" %}           {% assign prevyear = post.previous.date | date: "%y" %}           {% assign m = post.date | date: "%-m" %}           {% assign counter = counter | plus: 1 %}           {% if thisyear != prevyear %}             <li><a href="/archive/#{{ post.date | date:"%b %y" | }}">{% case m %}                   {% when '1' %}janvier                   {% when '2' %}février                   {% when '3' %}mars                   {% when '4' %}avril                   {% when '5' %}mai                   {% when '6' %}juin                   {% when '7' %}juillet                   {% when '8' %}août                   {% when '9' %}septembre                   {% when '10' %}octobre                   {% when '11' %}novembre                   {% when '12' %}décembre                 {% endcase %}{{ thisyear }}&nbsp;({{ counter }})</a></li>             {% assign counter = 0 %}           {% endif %}         {% endfor %}     </ul> 

with {% if thisyear != prevyear %}, you're grouping year only.

you need group month , year.

you print if :

  • not same month (thismonth != prevmonth)
  • or same month not same year (thisyear != prevyear , thismonth == prevmonth)

this works :

<ul> {% post in site.posts %}   {% assign thisyear = post.date | date: "%y" %}   {% assign thismonth = post.date | date: "%-m" %}   {% assign prevyear = post.previous.date | date: "%y" %}   {% assign prevmonth = post.previous.date | date: "%-m" %}   {% assign counter = counter | plus: 1 %}   {% if (thismonth != prevmonth) or (thisyear != prevyear , thismonth == prevmonth) %}     <li><a href="/archive/#{{ post.date | date:"%b %y" | }}">     {% case thismonth %}         [ month in french here ]     {% endcase %}     {{ thisyear }}&nbsp;({{ counter }})     </a></li>     {% assign counter = 0 %}   {% endif %} {% endfor %} </ul> 

Comments