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
...
Community guidelines
Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.
Solved by Karmalakas View solution
@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 %}
<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>
{% endif %}
{% if language.current == en %}
<span><i class="fa fa-clock-o"></i> {{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(child.header.date|date('n') - 1) }} {{ child.header.date|date('d') }} {{ child.header.date|date('Y') }}</span>
{% 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 :) I'll need it at some point anyway
Thanks a lot! It works!
Check this plugin I just created ;)
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 ;)
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 2 | 82 | 11 hours ago | ||
| 1 | 53 | 16 hours ago | ||
| 0 | 45 | 1 day ago | ||
| 6 | 347 | 5 days ago | ||
| 3 | 41 | 5 days ago |