Set date format per language in blog post

In the file blog_item.html.twig I have now this line:
<span><i class="fa fa-clock-o"></i> {{ child.header.date|date('d') }} {{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(child.header.date|date('n') - 1) }} {{ child.header.date|date('Y') }}</span>
This translates the names of the months brilliantly and in Dutch the date format is correct. In the English blog posts it is not: the day number should then be behind the name of the month. So perhaps there is a way to do something like this?:
{% if language.current = english %}
do this
{% else %}
do that

@TonHaarmans, What have you tried so far? Your suggestion doesn’t seem to be too difficult to give it a go…

I tried this:

{% if language.current == nl %}
{{ child.header.date|date(‘d’) }} {{ ‘GRAV.MONTHS_OF_THE_YEAR’|ta(child.header.date|date(‘n’) - 1) }} {{ child.header.date|date(‘Y’) }}
{% endif %}
{% if language.current == en %}
{{ ‘GRAV.MONTHS_OF_THE_YEAR’|ta(child.header.date|date(‘n’) - 1) }} {{ child.header.date|date(‘d’) }} {{ child.header.date|date(‘Y’) }}
{% endif %}

It doesn’t give an error, but it also does not work. I don’t even know if there is something like {% if language.current == en %}. I’m just guessing…

Try this:

{% if grav.language.getActive is same as('nl') %}
    <...>
{% elseif grav.language.getActive is same as('en') %}
    <...>
{% endif %}

I think I’ll try to make a simple plugin for this purpose after work :slight_smile: I’ll need it at some point anyway

Thanks a lot! It works!

Check this plugin I just created :wink:

Keep in mind it’s tested only on my local with two languages and only a few cases. If you try and find some problems, don’t hesitate to open an issue :wink: