Closed Fazarel closed 10 months ago
Hello. For the next release, the Grav language variable will be set to base.html.twig, so it will be extended to all templates.
Just in case: you also need to modify /templates/partials/simplesearch_item.html.twig
As it stands, add :
{% set lang = grav.language.getActive ? : grav.config.site.default_lang %}
{% if config.plugins["translate-date"].enabled %}
{% set datestamp = (page.header.publish_date) ? (page.header.publish_date|td(null, "Y-m-d")) : (page.date|td(null, "Y-m-d")) %}
{% elseif config.plugins["twig-extensions"].enabled %}
{% set datestamp = (page.header.publish_date) ? (page.header.publish_date|localizeddate('medium', 'none', lang)) : (page.date|localizeddate('medium', 'none', lang)) %}
{% else %}
{% set datestamp = (page.header.publish_date) ? (page.header.publish_date|date(system.pages.dateformat.short)) : (page.date|date(system.pages.dateformat.short)) %}
{% endif %}
And change <span class="search-date">{{ page.date|date(config.system.pages.dateformat.short) }}</span>
to <span class="search-date">{{ datestamp }}</span>
Thanks @Fazarel . I'm checking all files of template searching code like you suggest.
Fixed in version 2.0.0
The date translation is correct on the post page. This is not the case for the blog post listings (modular recent-posts and blog page).
In comparison with
/templates/item.html.twig
, you have to add{% set lang = grav.language.getActive ?: grav.config.site.default_lang %}
and change{{ datestamp|date(system.pages.dateformat.short) }}
to{{ datestamp }}
in:/templates/partials/blog-list-item.html.twig
and/templates/modular/recent-posts.html.twig
Tested with the Twig Extensions plugin, I haven't tried Translate Date. By the way, any arguments for using one rather than the other?